Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
15 lines (15 loc) · 5 KB
/
Copy pathindex.html
File metadata and controls
15 lines (15 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Wei / Gwei / Ether, Sats / BTC, Lamports / SOL unit converter | Blockchain Lab Tools</title><meta name="description" content="Exact big-number conversion between wei, gwei, ether, satoshis, BTC, lamports and SOL — no floating point errors."><link rel="canonical" href="https://blockchains.github.io/blockchainlab-tools/units/">
<meta property="og:title" content="Wei / Gwei / Ether, Sats / BTC, Lamports / SOL unit converter | Blockchain Lab Tools"><meta property="og:description" content="Exact big-number conversion between wei, gwei, ether, satoshis, BTC, lamports and SOL — no floating point errors."><meta property="og:image" content="https://blockchains.github.io/blockchainlab-tools/social-preview.png"><meta name="twitter:card" content="summary_large_image">
<link rel="stylesheet" href="../assets/app.css"><script type="importmap">{"imports":{"ethers":"https://cdn.jsdelivr.net/npm/ethers@6.13.4/+esm","@openzeppelin/merkle-tree":"https://esm.sh/@openzeppelin/merkle-tree@1.0.8","@scure/btc-signer":"https://esm.sh/@scure/btc-signer@2.0.1","@scure/base":"https://esm.sh/@scure/base@2.0.0"}}</script></head><body>
<nav><div class="wrap"><a class="brand" href="../">Blockchain Lab Tools</a><a href="../gas/" class="">Gas</a><a href="../units/" class="on">Units</a><a href="../abi/" class="">ABI</a><a href="../address/" class="">Address/ENS</a><a href="../tx/" class="">Tx decoder</a><a href="../hash/" class="">Hash/Merkle</a><select aria-label="All tools" onchange="location.href=this.value" style="width:auto;padding:4px 8px"><option value="">All 26 tools…</option><option value="../gas/">Gas</option><option value="../units/" selected>Units</option><option value="../abi/">ABI</option><option value="../address/">Address/ENS</option><option value="../tx/">Tx decoder</option><option value="../hash/">Hash/Merkle</option><option value="../storage/">Storage slots</option><option value="../reference/">EIP/ERC/BIP</option><option value="../chains/">Chainlist</option><option value="../tokens/">Tokens</option><option value="../safe/">Safe multisig</option><option value="../eip712/">EIP-712</option><option value="../calldiff/">Calldata diff</option><option value="../verify/">Verification</option><option value="../gas-history/">Gas history</option><option value="../bridge/">Bridge fees</option><option value="../approvals/">Approvals</option><option value="../ens-bulk/">ENS bulk</option><option value="../solana-tx/">Solana tx</option><option value="../psbt/">Bitcoin PSBT</option><option value="../labels/">Address labels</option><option value="../vanity/">Vanity/CREATE2</option><option value="../price-impact/">Price impact</option><option value="../mev/">MEV sandwich</option><option value="../stablecoins/">Stablecoins</option><option value="../rpc-health/">RPC health</option></select><a href="https://blockchains.github.io/">Hub</a></div></nav>
<main class="wrap"><h1>Unit converter</h1><p class="mut">Exact integer maths (BigInt via ethers.js). Type a value and pick its unit.</p>
<div class="card"><div class="row"><div><label>Value</label><input id="v" value="1"></div><div><label>Unit</label><select id="u"><option>wei</option><option selected>gwei</option><option>ether</option><option>kwei</option><option>mwei</option><option>szabo</option><option>finney</option><option>sat</option><option>btc</option><option>lamport</option><option>sol</option></select></div></div><button id="go">Convert</button></div><div id="out" class="card"></div>
<div class="card mut">Learn more on Blockchain Lab: <a href="https://blockchainlab.com/learn/fundamentals?utm_source=blockchainlab-tools&utm_medium=tool&utm_campaign=units">Fundamentals</a> · <a href="https://blockchainlab.com/learn/concepts/wallet?utm_source=blockchainlab-tools&utm_medium=tool&utm_campaign=units">Wallets</a> · <a href="https://blockchainlab.com/learn/glossary?utm_source=blockchainlab-tools&utm_medium=tool&utm_campaign=units">Glossary</a></div></main>
<footer><div class="wrap">Built by Blockchain Lab — <a href="https://blockchainlab.com/?utm_source=blockchainlab-tools&utm_medium=tool&utm_campaign=units">blockchainlab.com</a> · Runs entirely in your browser against public RPCs/APIs; nothing is sent to Blockchain Lab · <a href="https://github.com/Blockchains/blockchainlab-tools">Source</a> · <a href="https://blockchains.github.io/blockchainlab-api/">Open Data API</a> · Not financial advice.</div></footer>
<script type="module">
import * as C from "../assets/core.js"; import { $, esc, params, busy, fail, kv, table, json, on } from "../assets/ui.js";
function run(){ const out=$("#out"); try { const r=C.convertUnits($("#v").value,$("#u").value); out.innerHTML=kv(Object.fromEntries(Object.entries(r).map(([k,v])=>[k==="_hex"?"hex (base unit)":k,esc(v)]))); } catch(e){ fail(out,e); } }
if(params.get("v")) $("#v").value=params.get("v"); if(params.get("u")) $("#u").value=params.get("u");
on("go",run); $("#v").oninput=run; $("#u").onchange=run; run();
</script></body></html>