{"name":"micro-eth-signer","version":"0.4.2","keywords":["ethereum","eth","create","sign","validate","transaction","address","tx","web3","ethers","micro","nano","signer"],"author":{"url":"https://paulmillr.com","name":"Paul Miller"},"license":"MIT","_id":"micro-eth-signer@0.4.2","maintainers":[{"name":"paulmillr","email":"paul@paulmillr.com"}],"homepage":"https://github.com/paulmillr/micro-eth-signer#readme","bugs":{"url":"https://github.com/paulmillr/micro-eth-signer/issues"},"dist":{"shasum":"0231fb2c9497c4a0d1dfbdbafc7bdd203a1c50ce","tarball":"http://registry-npm.ywwl.com/micro-eth-signer/download/micro-eth-signer-0.4.2.tgz","fileCount":5,"integrity":"sha512-+wl03IbSsBhB8tlbKltOf7xk34aQpDcL4kjUlVhAvTw/ggea/S7oZpkbay7F/jnVuuWf0Q3LNVadTbLjnfoSGw==","signatures":[{"sig":"MEUCIHFhh9wSNOBV3DU2b64dqmJ8zxY5LV+8FsXCfhG7vKL9AiEAjh5YfRL4UU9hV1AAvwY07LrKj9VggSUrLB0lOjghvc8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29232,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhmbqhCRA9TVsSAnZWagAAnYsP/jTWUpLehiUt8Hxp2cvq\nZaCxZT98kZwi6iYtLh3Popjfip8U4gnjBjv1B5HaanWYMWdaE2al3pFS9Suv\nU019hkyVHGq4uhHRI+3Z/wPXQXK2JB+kFYhKF/5u6NqaSZtWOcrEFZWSprF/\n+fbyf5Zr545Ey0d2wwTEbiKd5888NFosRq92J9XQUCgrnV8to5VYJa+MRDU6\n35iZHb2ny/UxDaT1QEaZjSZDDVp0AVpDdJoYSeHyp2Vo0/zKP0KmVcO834Hk\nKzTpRvzxRXylXirdwDVDs9JHZv2zy/O1I1xh12lrvHJyOlli893A+LyVqGEz\ntSR4E+RB2Sm6CSYFpCLt1GYeI1HuuYT8Mf/qm/Ok6OyiQhuk/LgJoYA6ICyh\n/A18VYJ10xbGo9dTY2GQmgRO+csq4urgbgT5x/FMV2HFJZIDgfLyfjoYJzK1\nTCvo8ArSl6lSg86HZnT7NRY+FM6vFRVfegrz0DJWdpXWLioXFv5eaF8INYXe\nD0kfsPq/6BqWcmsT87RfChkpRC3nZITcJSbSVj8QC0JwlXejr3yYVTfPyC4c\nmhG9PTZN2mfU4ReoZXrho7PKNll2i3G5aHgJzDIErswArzORWPdc14AHbcEr\nAer9O9wPDTtdmfq6r4CkyPOK16oMmvfd5YYDZbGO9Ah8BHaE/juW+tCxWqQj\nrWO/\r\n=ZrcA\r\n-----END PGP SIGNATURE-----\r\n","size":8487,"noattachment":false,"key":"/micro-eth-signer/-/micro-eth-signer-0.4.2.tgz"},"jest":{"testRegex":"/test/.*?\\.ts","transform":{"^.+\\.ts$":"ts-jest"}},"main":"index.js","types":"./index.d.ts","gitHead":"7e2c5f1d3b1ac6113fd4ce32b46718d0237af24c","scripts":{"lint":"prettier --print-width 100 --single-quote --check index.ts","test":"node test/test.js","build":"tsc -d && rollup -c rollup.config.js"},"_npmUser":{"name":"paulmillr","email":"paul@paulmillr.com"},"repository":{"url":"git+https://github.com/paulmillr/micro-eth-signer.git","type":"git"},"_npmVersion":"8.1.0","description":"Create, sign and validate Ethereum transactions & addresses with minimum deps. Supports London & Berlin txs","directories":{},"_nodeVersion":"16.13.0","dependencies":{"micro-rlp":"2.2.9","@noble/hashes":"^0.4.1","@noble/secp256k1":"^1.3.0"},"_hasShrinkwrap":false,"devDependencies":{"rollup":"^2.42.4","prettier":"^2.2.1","typescript":"^4.2.3","micro-should":"^0.1.4","@rollup/plugin-commonjs":"^17.1.0","@rollup/plugin-node-resolve":"^11.2.0"},"_npmOperationalInternal":{"tmp":"tmp/micro-eth-signer_0.4.2_1637464737482_0.09042169672162736","host":"s3://npm-registry-packages"},"readme":"# micro-eth-signer\n\nMinimal privacy-focused Ethereum library.\n\n- 🔓 Core: audited [noble](https://paulmillr.com/noble/) cryptography, zero network access,\n  [hedged signatures](#transactions-create-sign), 10KB gzipped, tree-shakeable\n- 🦺 Opt-in modules: type-safe ABI with ERC-7730 Clear Signing, RLP, SSZ, KZG & PeerDAS, BLS keystores\n- 🕵️ Privacy-first networking: account history, token & NFT balances, prices, ENS, Uniswap\n  swaps — all derived from plain RPC against your own node. No Etherscan, no CoinGecko,\n  no OpenSea: no third parties to leak your addresses to\n- Reliable: 800MB of test vectors from EIPs, ethers and viem.\n\n_Check out all web3 utility libraries:_ [ETH](https://github.com/paulmillr/micro-eth-signer), [BTC](https://github.com/paulmillr/scure-btc-signer), [SOL](https://github.com/paulmillr/micro-sol-signer)\n\n## Usage\n\n> `npm install micro-eth-signer`\n\n> `jsr add jsr:@paulmillr/micro-eth-signer`\n\nWe support all major platforms and runtimes. React Native may need a\n[polyfill for getRandomValues](https://github.com/LinusU/react-native-get-random-values).\n\n- Core\n  - [Create random wallet](#create-random-wallet)\n  - [Transactions: create, sign](#transactions-create-sign)\n  - [Addresses: create, checksum](#addresses-create-checksum)\n  - [Messages: sign, verify](#messages-sign-verify)\n- Advanced\n  - [ABI parsing](#abi-parsing)\n  - [Clear Signing](#clear-signing)\n  - [Keystore: EIP-2333 & legacy](#keystore-eip-2333--legacy)\n  - [RLP & SSZ](#rlp--ssz)\n  - [KZG & PeerDAS](#kzg--peerdas)\n- RPC provider\n  - [Init network](#init-network)\n  - [Fetch balances and history](#fetch-balances--history)\n  - [Asset price quoting (uniswap, chainlink)](#asset-price-quoting-uniswap-chainlink)\n  - [Resolve ENS and GNS names](#resolve-ens-and-gns-names)\n  - [Swap tokens with Uniswap](#swap-tokens-with-uniswap)\n- [Security](#security)\n- [Speed](#speed)\n- [License](#license)\n\n## Core\n\n```ts\nimport { addr, authorization, Transaction } from 'micro-eth-signer';\nimport { eip191Signer, recoverAddressTyped, signTyped, verifyTyped } from 'micro-eth-signer';\nimport { amounts, ethHex, ethHexNoLeadingZero, weieth, weigwei } from 'micro-eth-signer';\n```\n\nCore is everything done offline with a secp256k1 key — the three kinds of payloads Ethereum\nsigns: transactions (`Transaction`), EIP-7702 authorizations (`authorization`), and messages\n(EIP-191 `eip191Signer`, EIP-712 `signTyped`), plus the addresses derived from those keys.\nHeavy or specialized codecs (ABI, keystores, KZG, SSZ) live in opt-in modules instead.\n\n### Create random wallet\n\n```ts\nimport { addr } from 'micro-eth-signer';\nconst random = addr.random(); // Secure: uses CSPRNG\nconsole.log(random.privateKey, random.address);\n// '0x17ed046e6c4c21df770547fad9a157fd17b48b35fe9984f2ff1e3c6a62700bae'\n// '0x26d930712fd2f612a107A70fd0Ad79b777cD87f6'\n```\n\n### Transactions: create, sign\n\n```ts\nimport { addr, Transaction, weigwei, weieth } from 'micro-eth-signer';\nconst random = addr.random();\nconst tx = Transaction.prepare({\n  to: '0xdf90dea0e0bf5ca6d2a7f0cb86874ba6714f463e',\n  value: weieth.decode('1.1'), // 1.1eth in wei\n  maxFeePerGas: weigwei.decode('100'), // 100gwei in wei (priority fee is 1 gwei)\n  nonce: 0n,\n});\n// Uses `random` from example above. Alternatively, pass 0x hex string or Uint8Array\nconst signedTx = tx.signBy(random.privateKey);\nconsole.log('signed tx', signedTx, signedTx.toHex());\nconsole.log('fee', signedTx.fee);\n\n// Hedged signatures, with extra noise / security\nconst tx2 = tx.signBy(random.privateKey, true); // default, same as above\nconst tx3 = tx.signBy(random.privateKey, false); // disable\n\n// Send the maximum amount while reserving the worst-case fee\nconst CURRENT_BALANCE = '1.7182050000017'; // in eth\nconst txSendingMaxAmount = tx.setMaxAmount(weieth.decode(CURRENT_BALANCE));\n```\n\nWe support legacy, EIP2930, EIP1559, EIP4844 and EIP7702 transactions.\n\nSigning is done with [noble-curves](https://github.com/paulmillr/noble-curves), using RFC 6979.\nHedged signatures are also supported - check out the blog post\n[Deterministic signatures are not your friends](https://paulmillr.com/posts/deterministic-signatures/).\n\n### Addresses: create, checksum\n\n```ts\nimport { addr } from 'micro-eth-signer';\nconst priv = '0x0687640ee33ef844baba3329db9e16130bd1735cbae3657bd64aed25e9a5c377';\nconst pub = '030fba7ba5cfbf8b00dd6f3024153fc44ddda93727da58c99326eb0edd08195cdb';\nconst nonChecksummedAddress = '0x0089d53f703f7e0843953d48133f74ce247184c2';\nconst checksummedAddress = addr.addChecksum(nonChecksummedAddress);\nconsole.log(\n  checksummedAddress, // 0x0089d53F703f7E0843953D48133f74cE247184c2\n  addr.isValid(checksummedAddress), // true\n  addr.isValid(nonChecksummedAddress), // also true\n  addr.fromPrivateKey(priv),\n  addr.fromPublicKey(pub)\n);\n\n// Contract addresses: CREATE (deployment tx) and CREATE2 (EIP-1014)\nconst factory = '0x8ba1f109551bD432803012645Ac136ddd64DBA72';\nconst salt = `0x${'00'.repeat(32)}`;\nconst initCodeHash = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470';\naddr.getCreateAddress(factory, 1n);\naddr.getCreate2Address(factory, salt, initCodeHash); // salt & initCodeHash are 32 bytes\n```\n\n### Messages: sign, verify\n\nThere are two messaging standards: [EIP-191](https://eips.ethereum.org/EIPS/eip-191) & [EIP-712](https://eips.ethereum.org/EIPS/eip-712).\n\n#### EIP-191\n\n```ts\nimport { eip191Signer } from 'micro-eth-signer';\n\n// Example message\nconst message = 'Hello, Ethereum!';\nconst privateKey = '0x4c0883a69102937d6231471b5dbb6204fe512961708279f1d7b1b8e7e8b1b1e1';\n\n// Sign the message\nconst signature = eip191Signer.sign(message, privateKey);\nconsole.log('Signature:', signature);\n\n// Verify the signature\nconst address = '0xYourEthereumAddress';\nconst isValid = eip191Signer.verify(signature, message, address);\nconsole.log('Is valid:', isValid);\n\n// The digest that gets signed (\"hashMessage\") is available directly:\neip191Signer.getHash(message);\n// 65-byte wallet signatures (r || s || v) can be split & rebuilt:\nimport { parseSignature, serializeSignature } from 'micro-eth-signer';\nconst { r, s, yParity } = parseSignature(signature); // v: 0/1 or 27/28\nserializeSignature({ r, s, yParity }); // back to 0x hex, v as 27/28\n```\n\n#### EIP-712\n\n```ts\nimport { addr, ethHex, recoverAddressTyped, signTyped, verifyTyped } from 'micro-eth-signer';\nimport type { EIP712Domain, TypedData } from 'micro-eth-signer';\n\nconst types = {\n  Person: [\n    { name: 'name', type: 'string' },\n    { name: 'wallet', type: 'address' },\n  ],\n  Mail: [\n    { name: 'from', type: 'Person' },\n    { name: 'to', type: 'Person' },\n    { name: 'contents', type: 'string' },\n  ],\n};\n\n// Define the domain\nconst domain: EIP712Domain = {\n  name: 'Ether Mail',\n  version: '1',\n  chainId: 1n,\n  verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n  salt: ethHex.decode('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'),\n};\n\n// Define the message\nconst message = {\n  from: {\n    name: 'Alice',\n    wallet: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n  },\n  to: {\n    name: 'Bob',\n    wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',\n  },\n  contents: 'Hello, Bob!',\n};\n\n// Create the typed data\nconst typedData: TypedData<typeof types, 'Mail'> = {\n  types,\n  primaryType: 'Mail',\n  domain,\n  message,\n};\n\n// Sign the typed data\nconst privateKey = '0x4c0883a69102937d6231471b5dbb6204fe512961708279f1d7b1b8e7e8b1b1e1';\nconst signature = signTyped(typedData, privateKey);\nconsole.log('Signature:', signature);\n\n// Verify the signature\nconst address = addr.fromPrivateKey(privateKey);\nconst isValid = verifyTyped(signature, typedData, address);\nconsole.log('Is valid:', isValid);\n\n// Recover the signer address\nconst recovered = recoverAddressTyped(signature, typedData);\nconsole.log('Recovered:', recovered);\n```\n\n## Advanced\n\n### ABI parsing\n\nThe ABI is type-safe when `as const` is specified:\n\n```ts\nimport { createContract } from 'micro-eth-signer/abi.js';\nconst PAIR_CONTRACT = [\n  {\n    type: 'function',\n    name: 'getReserves',\n    outputs: [\n      { name: 'reserve0', type: 'uint112' },\n      { name: 'reserve1', type: 'uint112' },\n      { name: 'blockTimestampLast', type: 'uint32' },\n    ],\n  },\n] as const;\n\nconst contract = createContract(PAIR_CONTRACT);\ntype Contract = typeof contract;\n// Contract type:\n// {\n//   getReserves: {\n//     encodeInput: () => Uint8Array;\n//     decodeOutput: (b: Uint8Array) => {\n//       reserve0: bigint;\n//       reserve1: bigint;\n//       blockTimestampLast: bigint;\n//     };\n//   };\n// }\n```\n\nHuman-readable signatures can be parsed into JSON ABI with `parseAbi` / `parseAbiItem`.\nParsed ABIs are runtime-only: `createContract` / `events` return string-indexed untyped\nmethods for them, so prefer `as const` JSON ABIs when type inference matters:\n\n```ts\nimport { createContract, parseAbi } from 'micro-eth-signer/abi.js';\nconst abi = parseAbi([\n  'function balanceOf(address owner) view returns (uint256)',\n  'event Transfer(address indexed from, address indexed to, uint256 value)',\n  'error InsufficientBalance(uint256 available, uint256 required)',\n]);\nconst erc20 = createContract(abi);\nerc20.balanceOf.encodeInput('0x6B175474E89094C44Da98b954EedeAC495271d0F');\n// Inline tuples work: 'function f((address a, uint256 b) point)'. Struct references don't.\n```\n\nRevert data of a failed call can be decoded with `decodeError`:\n\n```ts\nimport { decodeError, parseAbi } from 'micro-eth-signer/abi.js';\ndecodeError(\n  '0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001a4e6f7420656e6f7567682045746865722070726f76696465642e000000000000'\n); // { name: 'Error', message: 'Not enough Ether provided.', ... }\ndecodeError('0x4e487b710000000000000000000000000000000000000000000000000000000000000011'); // { name: 'Panic', message: 'panic: arithmetic overflow...', ... }\n// Custom errors are matched by selector against `type: 'error'` ABI entries:\ndecodeError(\n  '0xcf47918100000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000009',\n  parseAbi(['error InsufficientBalance(uint256 available, uint256 required)'])\n);\n```\n\nWe're parsing values as:\n\n```text\n// no inputs\n{} -> encodeInput();\n// single input\n{inputs: [{type: 'uint'}]} -> encodeInput(bigint);\n// all inputs named\n{inputs: [{type: 'uint', name: 'lol'}, {type: 'address', name: 'wut'}]} -> encodeInput({lol: bigint, wut: string})\n// at least one input is unnamed\n{inputs: [{type: 'uint', name: 'lol'}, {type: 'address'}]} -> encodeInput([bigint, string])\n// Same applies for output!\n```\n\nThere are following limitations:\n\n- Fixed size arrays can have 999 elements at max: string[], string[1], ..., string[999]\n- Fixed size 2d arrays can have 39 elements at max: string[][], string[][1], ..., string[39][39]\n- Which is enough for almost all cases\n- ABI must be described as constant value: `[...] as const`\n- We're not able to handle contracts with method overload (same function names with different args) — the code will still work, but not types\n\nCheck out [`src/net/resolver.ts`](./src/net/resolver.ts) for a type-safe contract execution example.\n\n### Clear Signing\n\nThe library supports [Clear Signing](https://clearsigning.org) through\nERC-7730 descriptor maps via `decodeTx`, `decodeData`, and `eip712`.\n\n#### ERC-7730 descriptor maps\n\n`CLEARSIG_REPO` is the batteries-included descriptor map: the generic ERC\ninterfaces (erc20/erc721/erc4626/...), curated and legacy contracts (uniswap\nv2/v3, kyber, weth), and the built-in token registry\nalready bound to them - including an ERC-2612 permit binding per token.\n\n```ts\nimport { CLEARSIG_REPO, addTokens } from 'micro-eth-signer/abi.js';\nimport { CLEARSIG_REPO_FULL } from 'micro-eth-signer/clearsig/repo-full.js';\n\n// basic: generic ERCs + curated contracts + built-in tokens\nconst base = CLEARSIG_REPO;\n\n// your own tokens: binds erc20/erc721 interfaces + an ERC-2612 permit per token\nconst mine = addTokens(CLEARSIG_REPO, {\n  '0x0000000000000000000000000000000000000123': {\n    abi: 'ERC20',\n    symbol: 'MTK',\n    decimals: 18,\n  },\n}); // chainId is optional, defaults to mainnet (1)\n\n// Explorer discovery carries `verified: false`; addTokens deliberately skips\n// those entries until the application explicitly promotes them to trusted data.\n\n// full: every descriptor from the upstream registry on top.\n// CLEARSIG_REPO_FULL is about 500KB of generated source; the normal ABI facade\n// does not re-export it, so import this separate subpath only when needed.\nconst full = { ...CLEARSIG_REPO, ...CLEARSIG_REPO_FULL };\n```\n\n#### ERC-7730 transactions\n\n`decodeTx` decodes a raw transaction through the built-in ABI and clear-signing\nregistries; matched transactions carry a `clearSig` promise with the rendered\nintent and fields. Use `decodeData(to, data, value, opts)` when you already\nhave RPC calldata fields instead of full transaction hex.\n\nBoth default to `CLEARSIG_REPO` when you omit `clearSig`; pass `{ clearSig }` to\noverride it - with `addTokens(...)` output or your own descriptor map. Each call\nreturns the exact decoded call (carrying `clearSig`), an array of ABI-shape\nguesses when no exact contract matches (these never carry `clearSig`), or\n`undefined` for unknown selectors and contract creation - so guard with\n`out && !Array.isArray(out)` before reading `clearSig`.\n\n```ts\nimport { decodeTx } from 'micro-eth-signer/abi.js';\n\nconst tx =\n  '0xf8a901851d1a94a20082c12a94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000000000000000000000000000000000054259870025a066fcb560b50e577f6dc8c8b2e3019f760da78b4c04021382ba490c572a303a42a0078f5af8ac7e11caba9b7dc7a64f7bdc3b4ce1a6ab0a1246771d7cc3524a7200';\nconst decoded = decodeTx(tx);\nif (!decoded || Array.isArray(decoded)) throw new Error('expected exact ABI match');\nconsole.log(decoded.value); // { to: '0xdac17f…31ec7', value: 22588000000n }\nconst clear = await decoded.clearSig;\nconsole.log(clear.interpolatedIntent);\n// 'Transfer 22588 USDT to 0xdac17f958d2ee523a2206206994597c13d831ec7'\nconsole.log(clear.fields);\n// { Amount: { value: '22588 USDT', format: 'tokenAmount', rawValue: 22588000000n },\n//   To: { value: '0xdac17f…31ec7', format: 'addressName', rawValue: '0xdac17f…31ec7' } }\n```\n\nThe user sees that sentence instead of raw calldata. Render `intent` as the headline and\n`fields` (label -> `{ value, format, rawValue }`) as detail rows. `interpolatedIntent` (a\nready-to-print sentence) and `structuredIntent` (the same sentence split into literals and\nformatted fields, for inline highlighting) are present only when the descriptor defines them —\nthe EIP-712 permit below renders with `intent` and `fields` alone.\n\nUnsigned transactions decode through the same `decodeTx` - here with a custom\ntoken bound via `addTokens`:\n\n```ts\nimport { Transaction } from 'micro-eth-signer';\nimport { CLEARSIG_REPO, addTokens, decodeData, decodeTx } from 'micro-eth-signer/abi.js';\n\nconst to = '0x7a250d5630b4cf539739df2c5dacb4c659f2488d';\nconst data =\n  '7ff36ab5000000000000000000000000000000000000000000000000ab54a98ceb1f0ad30000000000000000000000000000000000000000000000000000000000000080000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045000000000000000000000000000000000000000000000000000000006fd9c6ea0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000106d3c66d22d2dd0446df23d7f5960752994d600';\nconst value = 100000000000000000n;\nconst customContracts = {\n  '0x106d3c66d22d2dd0446df23d7f5960752994d600': { abi: 'ERC20', symbol: 'LABRA', decimals: 9 },\n} as const;\n\n// decodeData: for calldata fields you already have (to, data, value from RPC)\nconst call = decodeData(to, data, value, { customContracts });\n// { name: 'swapExactETHForTokens', signature: 'swapExactETHForTokens(uint256,address[],address,uint256)',\n//   value: { amountOutMin: 12345678901234567891n, path: [...], to: '0xd8da…6045', deadline: 1876543210n } }\n\n// decodeTx with a clear-signing map extended by the same tokens:\nconst unsigned = Transaction.prepare({\n  to,\n  value,\n  data,\n  nonce: 0n,\n  maxFeePerGas: 2000000000n,\n  gasLimit: 250000n,\n}).toHex({ includeSignature: false });\nconst decodedSwap = decodeTx(unsigned, { clearSig: addTokens(CLEARSIG_REPO, customContracts) });\nif (!decodedSwap || Array.isArray(decodedSwap)) throw new Error('expected exact ABI match');\nconsole.log((await decodedSwap.clearSig).interpolatedIntent);\n// 'Swap 0.1 ETH for at least 12345678901.234567891 LABRA. Expires at Tue, 19 Jun 2029 06:00:10 GMT'\n```\n\nERC-7730 does not describe plain value transfers (`data: '0x'`), so `decodeTx`\nproduces no `clearSig` for them; word those in the wallet itself (e.g.\n\"Send 0.5 ETH to ...\") instead of showing an unknown-transaction fallback.\n\n#### Network-backed metadata\n\n`discoverTx(prov, tx)` wires `decodeTx` to RPC-backed callbacks. The clear-signing\nrenderer stays no-network by default. Self-reported token and NFT metadata from\nRPC remains `verified: false`, so it cannot create a generic descriptor binding\nor trusted name. Block timestamps and factory proofs still resolve; applications\ncan pass curated `tokens` or their own trust-policy callbacks to opt in.\n\n```ts\nimport { RpcClient } from 'micro-eth-signer/net.js';\nimport { discoverTx } from 'micro-eth-signer/net/clearsig.js';\n\nasync function reviewTx(prov: RpcClient, txHex: string) {\n  const decoded = await discoverTx(prov, txHex);\n  if (!decoded || Array.isArray(decoded)) throw new Error('expected exact ABI match');\n  return decoded.clearSig;\n}\n```\n\nResolvers are independent of the network path: any `ClearSigOpt` callback -\n`resolveAddress`, `resolveToken`, `resolveNft`, `resolveBlock`, `resolveChain` -\ncan be passed to `decodeTx`/`eip712` alongside `clearSig`, e.g.\n`{ clearSig: CLEARSIG_REPO, resolveAddress: async ({ address }) => book[address] }`.\n`resolveAddress` is intentionally left out of `discoverTx`'s bundle - what counts\nas a trusted name is wallet policy. To teach the renderer about a non-token\ncontract, merge your own ERC-7730 descriptor files into the map\n(`{ ...CLEARSIG_REPO, ...myDescriptors }`); descriptor maps are plain\n`Record<string, ClearSigDef>`.\n\n#### EIP-712 typed data\n\n`eip712` defaults to `CLEARSIG_REPO` like `decodeTx`. Signature requests render\nthrough the same repository. `addTokens` gives every ERC-20 an ERC-2612 permit\nbinding (the upstream permit descriptor ships\nwithout deployments, so out of the box it matches nothing), and the bound\ntoken metadata makes amounts render offline:\n\n```ts\nimport { eip712 } from 'micro-eth-signer/abi.js';\nimport type { ClearSigTypedInput } from 'micro-eth-signer/abi.js';\n\nconst typed = {\n  types: {\n    Permit: [\n      { name: 'owner', type: 'address' },\n      { name: 'spender', type: 'address' },\n      { name: 'value', type: 'uint256' },\n      { name: 'nonce', type: 'uint256' },\n      { name: 'deadline', type: 'uint256' },\n    ],\n  },\n  primaryType: 'Permit',\n  domain: {\n    name: 'USD Coin',\n    version: '2',\n    chainId: 1,\n    verifyingContract: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',\n  },\n  message: {\n    owner: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',\n    spender: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',\n    value: 25000000n,\n    nonce: 0n,\n    deadline: 1893456000n,\n  },\n} as const;\nconst clear = (await eip712(typed as unknown as ClearSigTypedInput))!;\nconsole.log(clear.intent); // 'Authorize spending of tokens'\nconsole.log(clear.fields['Max spending amount']);\n// { value: '25 USDC', format: 'tokenAmount', rawValue: 25000000n }\n// other fields: Spender (raw address), 'Valid until' (date)\n```\n\n#### Decoding events\n\nReceipt logs are post-transaction facts, not ERC-7730 signing prompts. Minimal\nevent hints still exist for decoded token events:\n\n```ts\nimport { decodeEvent } from 'micro-eth-signer/abi.js';\n\nconst to = '0x0d8775f648430679a709e98d2b0cb6250d2887ef';\nconst topics = [\n  '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925',\n  '0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045',\n  '0x000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564',\n];\nconst data = '0x00000000000000000000000000000000000000000000003635c9adc5dea00000';\nconst event = decodeEvent(to, topics, data)!;\n// Arrays are ABI topic guesses used when no exact contract match is available.\nif (Array.isArray(event)) throw new Error('expected exact event match');\nconsole.log(event.name, event.value);\n// 'Approval', { value: 1000000000000000000000n, owner: '0xd8da…6045', spender: '0xe592…1564' }\nconsole.log(event.hint);\n// 'Allow 0xe592427a0aece92de3edee1f18e0157c05861564 spending up to 1000 BAT from 0xd8da6bf26964af9d7eed9e03e53415d37aa96045'\n```\n\n### Keystore: EIP-2333 & legacy\n\n`micro-eth-signer/keystore.js` implements various keystores:\n\n- The module exposes EIP-2333, EIP-2334, and EIP-2335 for Ethereum consensus validator keys\n- It also implements legacy v3 / sale keystores.\n- bip32 is not included, but can be easily combined with [scure-bip32](https://github.com/paulmillr/scure-bip32)\n- bip39 can be used from [scure-bip39](https://github.com/paulmillr/scure-bip39)\n\nPublic helpers:\n\n- `hkdfModR`, `deriveMaster`, `deriveChild`, `deriveSeedTree`: low-level EIP-2333 / EIP-2334 BLS key derivation.\n- `deriveEIP2334Key`, `deriveEIP2334SigningKey`: derive validator withdrawal or signing keys and paths.\n- `EIP2335Keystore`, `decryptEIP2335Keystore`: encrypt and decrypt EIP-2335 consensus-layer keystore objects.\n- `createDerivedEIP2334Keystores`: export multiple EIP-2335 keystores from one seed and password.\n- `privToLegacyKeystore`, `privFromLegacyKeystore`: export and import execution-layer Web3 v3 keystores.\n- `privFromLegacySaleKeystore`: import Ethereum legacy sale wallet files.\n\nOnline demo: [eip2333-tool](https://iancoleman.io/eip2333/)\n\n> `npm install @scure/bip39` for mnemonic-to-seed helpers\n\n```ts\nimport { mnemonicToSeedSync } from '@scure/bip39';\nimport {\n  createDerivedEIP2334Keystores,\n  decryptEIP2335Keystore,\n} from 'micro-eth-signer/keystore.js';\n\nconst password = 'my_password';\nconst mnemonic = 'letter advice cage absurd amount doctor acoustic avoid letter advice cage above';\nconst keyType = 'signing'; // or 'withdrawal'\nconst indexes = [0, 1, 2, 3]; // create 4 keys\n\nconst keystores = createDerivedEIP2334Keystores(\n  password,\n  'scrypt',\n  mnemonicToSeedSync(mnemonic, ''),\n  keyType,\n  indexes\n);\nconst firstPrivateKey = decryptEIP2335Keystore(keystores[0], password);\n```\n\nLegacy Web3 v3 keystores protect execution-layer secp256k1 account keys:\n\n```ts\nimport { addr } from 'micro-eth-signer';\nimport { privFromLegacyKeystore, privToLegacyKeystore } from 'micro-eth-signer/keystore.js';\n\nconst account = addr.random();\nconst legacyStore = await privToLegacyKeystore(account.privateKey, 'my_password');\nconst recoveredPrivateKey = await privFromLegacyKeystore(legacyStore, 'my_password');\n```\n\n> `privFromLegacySaleKeystore` is an offline migration API. Its compatibility error messages can\n> distinguish invalid CBC padding from a later address mismatch. Never return those errors from a\n> remote service: catch every failure at the trust boundary, replace it with one generic “invalid\n> sale keystore or passphrase” response, and rate-limit attempts.\n\n### RLP & SSZ\n\n```ts\nimport { RLP } from 'micro-eth-signer/core/rlp.js';\n// More RLP examples in test/rlp.test.ts\nRLP.decode(RLP.encode('dog'));\n```\n\n```ts\nimport * as ssz from 'micro-eth-signer/ssz.js';\n// More SSZ examples in test/ssz.test.ts\n```\n\nSSZ includes EIP-7688 progressive containers.\n\n> The legacy `ElectraBeaconBlock` and `ElectraSignedBeaconBlock` exports use a progressive block\n> body and do not compute consensus Electra Merkle roots. Use\n> `ETH2_PROFILES.electra.BeaconBlock` and `ETH2_PROFILES.electra.SignedBeaconBlock` for signing or\n> verification. Their legacy behavior is retained for compatibility.\n\n### KZG & PeerDAS\n\nAllows to create & verify KZG [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) proofs.\nSupports PeerDAS from [EIP-7594](https://eips.ethereum.org/EIPS/eip-7594).\n\n> `npm install @paulmillr/trusted-setups`\n\n```ts\nimport { KZG } from 'micro-eth-signer/kzg.js';\n// 400kb, 4-sec init\nimport { trustedSetup } from '@paulmillr/trusted-setups/small-kzg.js';\n\n// 800kb, instant init\n// import { trustedSetup } from '@paulmillr/trusted-setups/fast-kzg.js';\n// PeerDAS EIP-7594\n// import { trustedSetup } from '@paulmillr/trusted-setups/small-peerdas.js';\n// import { trustedSetup } from '@paulmillr/trusted-setups/fast-peerdas.js';\n\n// More KZG examples in\n// https://github.com/ethereumjs/ethereumjs-monorepo\n\nconst kzg = new KZG(trustedSetup);\n\n// Example blob and scalar\nconst blob = new Array(4096).fill(0n);\nconst commitment = kzg.blobToKzgCommitment(blob);\nconst z = 1n;\n\n// Compute and verify proof\nconst [proof, y] = kzg.computeProof(blob, z);\nconsole.log('Commitment:', commitment);\nconsole.log('Proof:', proof);\nconsole.log('Y:', y);\nconst isValid = kzg.verifyProof(commitment, z, y, proof);\nconsole.log('Is valid:', isValid);\n\nconst blobProof = kzg.computeBlobProof(blob, commitment);\nconsole.log('Blob proof:', blobProof);\nconsole.log('Blob proof valid:', kzg.verifyBlobProof(blob, commitment, blobProof));\n```\n\n## RPC provider\n\nMost wallets leak their users' address sets to third parties: an indexer API for history, a\nprice API for balances, an NFT API for images. Everything in this layer is instead derived from\nstandard `eth_*` RPC (plus optional OtterScan/trace namespaces): history via on-node discovery,\ntoken and NFT state via contract reads, prices via on-chain Chainlink and Uniswap pools, ENS via\nthe registry. The only party that sees your queries is the node you choose — run your own and\nnothing leaves your machine. NFT images are the single exception: metadata lives on external\nhosts, so the IPFS gateway is caller-chosen (`ipfsToHttp`).\n\n> `npm install micro-ftch`\n\n### Init network\n\neth-signer is network-free and makes it easy to audit network-related code:\nall requests are done with user-provided function, conforming to built-in `fetch()`.\nWe recommend using [micro-ftch](https://github.com/paulmillr/micro-ftch),\nwhich implements kill-switch, logging, batching / concurrency and other features.\n\nMost network APIs expect an instance of `RpcClient`.\nThe call stack would look like this:\n\n- `Quoter` => `RpcClient` => `jsonrpc` => `fetch`\n\nTo initialize RpcClient, do the following:\n\n```js\n// Requests are made with fetch(), a built-in method\nimport { jsonrpc } from 'micro-ftch';\nimport { RpcClient } from 'micro-eth-signer/net.js';\nconst RPC_URL = 'http://localhost:8545';\nconst prov = new RpcClient(jsonrpc(fetch, RPC_URL));\n\n// Example using mewapi RPC\nconst RPC_URL_2 = 'https://nodes.mewapi.io/rpc/eth';\nconst prov2 = new RpcClient(jsonrpc(fetch, RPC_URL_2, { Origin: 'https://www.myetherwallet.com' }));\n```\n\nmicro-ftch can batch many JSON-RPC calls into a single HTTP request. Helpers such as\n`tokenBalances` and `tokenInfo` can fire many small calls, so enabling it is a multi-x latency\nwin:\n\n```js\nconst prov = new RpcClient(jsonrpc(fetch, RPC_URL, { batchSize: 20 }));\n```\n\nAll network examples below assume a `prov` initialized as above.\n\n#### Conventions\n\n- All timestamps (e.g. `BlockInfo.timestamp`) are Unix **seconds**, as everywhere in Ethereum.\n  Multiply by 1000 for `Date()`.\n- Quantities which fit a JS number safely (block numbers, indexes, sizes) are `number`;\n  everything measured in wei / token units (balances, fees, gas) is `bigint`.\n- Addresses are returned as the node reports them: lowercase in logs, checksummed elsewhere.\n  Compare case-insensitively, or normalize with `addr.addChecksum` from the core module.\n- Methods throw on failure; `Web3Error` carries `method`, `rpcCode` and `isRevert`. The exception\n  is per-contract errors in batch methods (`tokenInfo`, `tokenBalances`), which return\n  `{ contract, error }` values so one broken token can't fail a whole batch.\n- Methods needing more than a basic node say so in errors; probe support upfront with\n  `prov.capabilities()`. Address history prefers OtterScan's `ots_*` namespace and falls back to\n  token-only `eth_getLogs` discovery.\n\n### Send transactions\n\nThe whole wallet loop — fetch nonce/fees/gasLimit, sign, broadcast, wait for inclusion:\n\n```ts\nimport { Transaction } from 'micro-eth-signer';\n\nasync function main(privateKey: string) {\n  const fields = await prov.prepare({\n    from: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',\n    to: '0x7aa96045d8da6bf26964af9d7eed9e03e53415d3',\n    value: 10n ** 18n, // 1 eth in wei\n  });\n  const tx = Transaction.prepare(fields).signBy(privateKey);\n  const txHash = await prov.broadcast(tx);\n  const receipt = await prov.waitForReceipt(txHash, { confirmations: 2 });\n  console.log(receipt.status === 1 ? 'confirmed' : 'reverted');\n}\n```\n\n`prepare` defaults to viem v3-compatible population: it tries `eth_fillTransaction`, caches nodes\nthat do not support it, and falls back to a pending nonce, exact `estimateGas()`, and viem-style\nfees (`1.2 * latest base fee + eth_maxPriorityFeePerGas`, with viem's gas-price fallbacks).\nPass `'ethers_v6'` as the second argument (`prov.prepare(args, 'ethers_v6')`) for ethers v6-compatible\nmanual population: no fill call, `2 * latest base fee + priority fee`, a 1 gwei priority fallback,\nand an unscaled legacy gas price. These two fixed policies are the only supported choices.\n`waitForReceipt` accepts `{ confirmations, timeoutMs, pollIntervalMs, signal }`.\n\nRead-only calls can be batched into a single request through\n[Multicall3](https://www.multicall3.com) (`aggregate3`, canonical deployment by default):\n\n```ts\nconst [name, symbol] = await prov.multicall([\n  { to: token, data: nameCalldata },\n  { to: token, data: symbolCalldata, allowFailure: false },\n]);\n// [{ success: true, data: '0x...' }, ...]\n```\n\n### Fetch balances & history\n\n`history()` streams wallet-grade rows. OtterScan-capable nodes get indexed discovery\n(`source: 'auto'`); basic nodes fall back to `eth_getLogs`, whose rows are marked\n`partial: 'tokens-only'` since plain/internal ETH-only transactions are invisible in logs.\n`order: 'newest'` (default) pages backward with the `before` cursor; `order: 'oldest'` walks\nforward with `after` — the direction for resumable sync (persist the last row's `block`).\n`internal: true` adds per-transaction traces. Passing an address array merges several addresses into one\ndeduplicated stream, re-deriving every row for the set as one wallet. Full option and row\nsemantics live in the `HistoryOpts`/`HistoryTx` JSDoc; range-crawled `trace_filter` helpers in\n`micro-eth-signer/net/trace.js`.\n\n```ts\nimport { history } from 'micro-eth-signer/net/history.js';\n\nconst addr = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';\nasync function main() {\n  const block = await prov.blockInfo(await prov.height());\n  console.log('current block', block.number, block.timestamp, block.baseFeePerGas);\n  console.log('info for addr', addr, await prov.accountState(addr));\n  for await (const tx of history(prov, addr, { depth: 'page', internal: true })) {\n    console.log(tx.hash, tx.diff, tx.tokenTransfers, tx.internal);\n  }\n}\n```\n\n`RpcClient` covers transport and wallet lifecycle (`prepare`, `broadcast`, `waitForReceipt`,\n`blockInfo`, `ethLogs`, `txInfo`, `capabilities`, typed `contract`). Higher-level free functions\nship per module — history, enrich, tokens/NFTs under `micro-eth-signer/net/*.js` — with full\nsignatures in each module's JSDoc.\n\n### Enrich transactions: token discovery & clear signing\n\n`enrichTx()` is the row primitive behind `history()`: one transaction as a wallet-grade row, for\ndetail pages or receipts already in hand. Unknown token contracts are discovered and decoded on\nthe fly; discovered metadata carries `verified: false` — it is attacker-controlled (symbols can\nbe phishing URLs), so render it distinctly from registry tokens. Clear-signing tiers: `'offline'`\n(default) fills `method` and curated intents with zero extra RPC; lazy `row.clearSig()` or\n`clearSig: 'resolve'` runs the full ERC-7730 resolvers. Discovered metadata remains visible in\ntransfer rows but cannot create an intent. Only bundled/explicit descriptors and verified\nresolver data belong on a signing screen.\n\n```ts\nimport { enrichTx, rowCodec } from 'micro-eth-signer/net/enrich.js';\nimport { history } from 'micro-eth-signer/net/history.js';\nimport { nftCandidates, nftHoldings } from 'micro-eth-signer/net/tokens.js';\n\nasync function main() {\n  const cache = new Map(); // one per session: dedupes discovery, speeds up clear signing\n  const row = await enrichTx(prov, txHash, { address: addr, cache });\n  console.log(row.method, row.intent, row.tokenTransfers);\n  console.log(await row.clearSig?.()); // full ERC-7730 resolution, lazy + memoized\n\n  // history() rows can opt into the same enrichment:\n  const discovered = [];\n  const rows = [];\n  for await (const tx of history(prov, addr, {\n    discover: true,\n    onToken: (t) => discovered.push(t),\n  }))\n    rows.push(tx);\n  // `discovered` metadata and rows are plain data; persist them across sessions:\n  localStorage.rows = rowCodec.encode(rows); // bigint/Map-safe JSON\n  // history is discovery, current state is truth — verify NFT ownership on-chain:\n  const held = await nftHoldings(prov, addr, nftCandidates(rows));\n}\n```\n\nAutomatic receipt enrichment probes at most 32 unknown contracts per receipt, two at a time;\nremaining transfer-shaped logs still decode with unverified shape metadata. NFT candidate and\nholdings calls accept at most 256 contracts and 4096 distinct contract/token-ID pairs per call,\nand ERC-1155 balance reads use batches of 128. Paginate larger indexed inventories.\n\n### Asset price quoting (uniswap, chainlink)\n\n```ts\nimport { DEFAULT_TOKENS } from 'micro-eth-signer/abi.js';\nimport { Quoter } from 'micro-eth-signer/net/quoter.js';\n\nasync function main() {\n  const quoter = new Quoter(prov, { chainlinkMaxAgeSec: 3600 });\n  const btc = await quoter.coinPrice('BTC'); // Chainlink is the default provider.\n  const bat = await quoter.tokenPrice('BAT');\n\n  const ethV2 = await quoter.coinPrice('ETH', 'uniswap-v2');\n  const ethV3 = await quoter.coinPrice('ETH', 'uniswap-v3', { fees: [500, 3000] });\n  const btc_eur = await quoter.coinPrice('BTC', 'uniswap-v3', { priceIn: 'EUR' });\n  console.log({ btc, btc_eur, bat, ethV2, ethV3 }); // prices in USD\n}\n\nconst quoterWithCustomToken = new Quoter(prov, {\n  // `tokens` replaces the built-in table. Spread DEFAULT_TOKENS when extending it.\n  tokens: {\n    ...DEFAULT_TOKENS,\n    '0x0000000000000000000000000000000000000001': {\n      symbol: 'MYT',\n      decimals: 18,\n      feed: {\n        contract: '0x0000000000000000000000000000000000000002',\n        decimals: 8,\n        maxAgeSec: 3600,\n      },\n    },\n  },\n});\n```\n\nUniswap quote helpers default to USDT prices and can discover pairs or pools from the requested\nasset before the first quote. Pass `priceIn` to use another quote token, or use\n`rate(amount, provider, params)` for raw pair, pool, and vault conversions. `priceIn` accepts token\naddresses, built-in token symbols such as `USDC` or `WBTC`, and the `EUR`/`EURC` aliases for\nmainnet EURC. Uniswap v3 EUR/EURC auto prices route through USDC to avoid thin direct pools.\nCall `quoter.clearRoutes()` to force auto-discovered Uniswap routes to be refreshed.\nV3 auto-discovery deduplicates fee tiers and accepts at most 32 unique tiers per request.\nChainlink quotes reject future timestamps and stale rounds. Built-in BTC/ETH feeds allow two hours;\nother feeds allow 26 hours. Override this per quoter with `chainlinkMaxAgeSec`, per explicit quote\nwith `{ maxAgeSec }`, or per custom token feed as shown above. Numeric historical block tags compare\nfreshness against that block's timestamp; `{ nowSec }` provides an explicit reference for offline\nor deterministic replay.\n\n### Resolve ENS and GNS names\n\n`NameResolver` handles both ENS and [Gwei Name Service](https://gwei.domains). GNS is an\nownerless ENS alternative: `.gwei` names are ERC-721 tokens whose ids are EIP-137 namehashes,\nwith registration fees burned instead of collected. Same contract address on Ethereum mainnet\nand Sepolia. Forward resolution routes by TLD (`.gwei` goes to GNS, everything else to ENS);\nreverse resolution takes an explicit mode, defaulting to ENS.\n\n```ts\nimport { gnsRegistrationFee, gnsTokenId, NameResolver } from 'micro-eth-signer/net/resolver.js';\n\nconst resolver = new NameResolver(prov);\nasync function main() {\n  const vitalikAddr = await resolver.nameToAddress('vitalik.eth');\n  const aliceAddr = await resolver.nameToAddress('alice.gwei');\n  if (!vitalikAddr || !aliceAddr) throw new Error('name not found');\n  const primary = await resolver.addressToName(vitalikAddr); // ENS by default\n  const gweiPrimary = await resolver.addressToName(aliceAddr, 'gns');\n  const avatar = await resolver.getText('alice.gwei', 'avatar'); // works for ENS names too\n  const free = await resolver.isAvailable('alice'); // GNS registration read\n}\n// Offline helpers: namehash('vitalik.eth') => EIP-137 node,\n// gnsTokenId('alice.gwei') => ERC-721 token id (EIP-137 namehash),\n// gnsRegistrationFee('alice') => burned fee in wei (fixed byte-length schedule).\n// Other reads: getContenthash, getAddrForCoin (SLIP-44), expiresAt, premium.\n```\n\nGNS registration itself is on-chain commit-reveal (`commit`/`reveal` on the NameNFT contract) and\nis not wrapped here; use the official dapp or build the calls with `micro-eth-signer/abi.js`.\n\n### Swap tokens with Uniswap\n\n> Btw cool tool, glad you built it!\n\n_Uniswap Founder_\n\nSwap 12.12 USDT to BAT with uniswap V3 defaults of 0.5% slippage, 30 min expiration.\n\n```js\nimport { tokenFromSymbol } from 'micro-eth-signer/abi.js';\nimport { UniswapV2, UniswapV3 } from 'micro-eth-signer/net/uniswap.js';\n\nconst USDT = tokenFromSymbol('USDT');\nconst BAT = tokenFromSymbol('BAT');\nif (!USDT || !BAT) throw new Error('unknown token');\nconst u3 = new UniswapV3(prov); // or new UniswapV2(provider)\nconst fromAddress = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';\nconst toAddress = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';\nasync function main() {\n  const swap = await u3.swap(USDT, BAT, '12.12', { slippagePercent: 0.5, ttl: 30 * 60 });\n  if (!swap) throw new Error('No swap route found');\n  const swapData = await swap.tx(fromAddress, toAddress);\n  console.log(swapData.amount, swapData.expectedAmount, swapData.allowance);\n}\n```\n\n## Security\n\n- **Commits** are signed with PGP keys to prevent forgery. Be sure to verify the commit signatures\n- **Releases** are made transparently through token-less GitHub CI and Trusted Publishing. Be sure to verify the [provenance logs](https://docs.npmjs.com/generating-provenance-statements) for authenticity.\n\nMain points to consider when auditing the library:\n\n- ABI correctness\n  - All ABI JSON should be compared to some external source\n  - There are different databases of ABI: one is hosted by Etherscan, when you open contract page\n- Network access\n  - There must be no network calls in the library\n  - Some functionality requires network: these need an external network interface conforming to `IWeb3Provider`\n  - `createContract(abi)` should create purely offline contract\n  - `createContract(abi, net)` would create contract that calls network using `net`, using external interface\n- Skipped test vectors\n  - There is `SKIPPED_ERRORS`, which contains list of test vectors from other libs that we skip\n  - They are skipped because we consider them invalid, or so\n  - If you believe they're skipped for wrong reasons, investigate and report\n\nThe library is cross-tested against other libraries (last update on 25 Feb 2024):\n\n- ethereum-tests v13.1\n- ethers 6.11.1\n- viem v2.7.13\n\nCheck out article [ZSTs, ABIs, stolen keys and broken legs](https://github.com/paulmillr/micro-eth-signer/discussions/20) about caveats of secure ABI parsing found during development of the library.\n\n### Privacy considerations\n\nDefault priority fee is 1 gwei, which matches what other wallets have.\nHowever, it's recommended to fetch recommended priority fee from a node.\n\n### Sending the maximum amount\n\n`setMaxAmount` sets the largest transaction value that still covers its worst-case fee:\n\n```ts\nimport { Transaction, weigwei, weieth } from 'micro-eth-signer';\nconst tx = Transaction.prepare({\n  to: '0xdf90dea0e0bf5ca6d2a7f0cb86874ba6714f463e',\n  value: weieth.decode('1.1'),\n  maxFeePerGas: weigwei.decode('100'),\n  nonce: 0n,\n});\nconst CURRENT_BALANCE = '1.7182050000017'; // in eth\nconst txSendingMaxAmount = tx.setMaxAmount(weieth.decode(CURRENT_BALANCE));\n```\n\nIt sets `amount = accountBalance - transaction.fee`, where `transaction.fee` is the maximum fee.\nIt does not change `gasPrice`, `maxFeePerGas`, or `maxPriorityFeePerGas`, preserving fee policies\nsuch as `viem_v3` and `ethers_v6`. When the actual fee is lower than the maximum, the difference\nremains in the account as dust.\n\n> [!WARNING]\n> Using the method would decrease privacy of a transfer, because\n> payments for services have specific amounts, rather than the maximum spendable amount.\n\n## Speed\n\n> `npm run bench`\n\n> [!NOTE]\n> The first call of `sign` will take 20ms+ due to noble-curves secp256k1 BASE point precompute.\n\nHighlights against ethers and viem: transaction-hash decoding is ~1.5x faster than ethers,\nsigning is on par, and the native-JS KZG initializes in 4ms versus 190ms for WASM builds while\nverifying proofs at comparable speed. Benchmark numbers age quickly — run `npm run bench` in\n`benchmark/` for current ones.\n\n## Contributing\n\nMake sure to use recursive cloning for the [eth-vectors](https://github.com/paulmillr/eth-vectors) submodule:\n\n    git clone --recursive https://github.com/paulmillr/micro-eth-signer.git\n\n## License\n\nMIT License\n\nCopyright (c) 2021 Paul Miller (https://paulmillr.com)\n","publish_time":1637464737666,"_cnpm_publish_time":1637464737666,"dist-tags":{"latest":"0.20.1"}}