{"id":15631766,"url":"https://github.com/paulmillr/micro-eth-signer","last_synced_at":"2025-05-15T12:06:19.860Z","repository":{"id":44418500,"uuid":"351858055","full_name":"paulmillr/micro-eth-signer","owner":"paulmillr","description":"Minimal library for Ethereum transactions, addresses and smart contracts.","archived":false,"fork":false,"pushed_at":"2025-05-11T12:10:14.000Z","size":1445,"stargazers_count":209,"open_issues_count":2,"forks_count":18,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-11T13:24:14.997Z","etag":null,"topics":["address","eip1559","eip4844","eip7702","eth","ethereum","ethers","kzg","signature","signer","signing","ssz","transaction","validate","verkle","viem","web3"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulmillr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"paulmillr"}},"created_at":"2021-03-26T17:16:24.000Z","updated_at":"2025-05-11T12:10:18.000Z","dependencies_parsed_at":"2024-02-28T05:29:50.506Z","dependency_job_id":"f6305e54-0a89-4109-a051-8adc1cc9e22f","html_url":"https://github.com/paulmillr/micro-eth-signer","commit_stats":{"total_commits":215,"total_committers":4,"mean_commits":53.75,"dds":"0.023255813953488413","last_synced_commit":"e8f2fc7a7072edd53ac6b02e8179fdcc4ce9db51"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulmillr%2Fmicro-eth-signer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulmillr%2Fmicro-eth-signer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulmillr%2Fmicro-eth-signer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulmillr%2Fmicro-eth-signer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulmillr","download_url":"https://codeload.github.com/paulmillr/micro-eth-signer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337613,"owners_count":22054253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["address","eip1559","eip4844","eip7702","eth","ethereum","ethers","kzg","signature","signer","signing","ssz","transaction","validate","verkle","viem","web3"],"created_at":"2024-10-03T10:41:29.082Z","updated_at":"2025-05-15T12:06:14.846Z","avatar_url":"https://github.com/paulmillr.png","language":"JavaScript","funding_links":["https://github.com/sponsors/paulmillr"],"categories":["Code"],"sub_categories":["Tooling support"],"readme":"# micro-eth-signer\n\nMinimal library for Ethereum transactions, addresses and smart contracts.\n\n- 🔓 Secure: audited [noble](https://paulmillr.com/noble/) cryptography, no network code, [hedged signatures](#transactions-create-sign)\n- 🔻 Tree-shakeable: unused code is excluded from your builds\n- 🔍 Reliable: 150MB of test vectors from EIPs, ethers and viem\n- ✍️ Core: transactions, addresses, messages\n- 🌍 Network-related: execute Uniswap \u0026 Chainlink, fetch tx history\n- 🦺 Advanced: type-safe ABI parsing, RLP, SSZ, KZG, Verkle\n- 🪶 29KB gzipped (1300 lines) for core, just 3 deps\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\u003e `npm install micro-eth-signer`\n\n\u003e `jsr add jsr:@paulmillr/micro-eth-signer`\n\nWe support all major platforms and runtimes.\nFor React Native, you may need a [polyfill for getRandomValues](https://github.com/LinusU/react-native-get-random-values).\nIf you don't like NPM, a standalone [eth-signer.js](https://github.com/paulmillr/micro-eth-signer/releases) is also available.\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- Network-related\n  - [Init network](#init-network)\n  - [Fetch balances and history](#fetch-balances-and-history-from-an-archive-node)\n  - [Fetch Chainlink oracle prices](#fetch-chainlink-oracle-prices)\n  - [Resolve ENS address](#resolve-ens-address)\n  - [Swap tokens with Uniswap](#swap-tokens-with-uniswap)\n- Advanced\n  - [Type-safe ABI parsing](#type-safe-abi-parsing)\n  - [Human-readable transaction hints](#human-readable-transaction-hints)\n  - [Human-readable event hints](#human-readable-event-hints)\n  - [RLP \u0026 SSZ](#rlp--ssz)\n  - [KZG \u0026 Verkle](#kzg--verkle)\n- [Security](#security)\n- [Performance](#performance)\n- [License](#license)\n\n## Core\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 { Transaction, weigwei, weieth } from 'micro-eth-signer';\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 signedTx2 = tx.signBy(random.privateKey, { extraEntropy: true });\n\n// Send whole account balance. See Security section for caveats\nconst CURRENT_BALANCE = '1.7182050000017'; // in eth\nconst txSendingWholeBalance = unsignedTx.setWholeAmount(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\n### Messages: sign, verify\n\nThere are two messaging standards: [EIP-191](https://eips.ethereum.org/EIPS/eip-191) \u0026 [EIP-712](https://eips.ethereum.org/EIPS/eip-712).\n\n#### EIP-191\n\n```ts\nimport * as typed from 'micro-eth-signer/typed-data';\n\n// Example message\nconst message = 'Hello, Ethereum!';\nconst privateKey = '0x4c0883a69102937d6231471b5dbb6204fe512961708279f1d7b1b8e7e8b1b1e1';\n\n// Sign the message\nconst signature = typed.personal.sign(message, privateKey);\nconsole.log('Signature:', signature);\n\n// Verify the signature\nconst address = '0xYourEthereumAddress';\nconst isValid = typed.personal.verify(signature, message, address);\nconsole.log('Is valid:', isValid);\n```\n\n#### EIP-712\n\n```ts\nimport * as typed from 'micro-eth-signer/typed-data';\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: typed.EIP712Domain = {\n  name: 'Ether Mail',\n  version: '1',\n  chainId: 1,\n  verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n  salt: '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: typed.TypedData\u003ctypeof types, 'Mail'\u003e = {\n  types,\n  primaryType: 'Mail',\n  domain,\n  message,\n};\n\n// Sign the typed data\nconst privateKey = '0x4c0883a69102937d6231471b5dbb6204fe512961708279f1d7b1b8e7e8b1b1e1';\nconst signature = typed.signTyped(typedData, privateKey);\nconsole.log('Signature:', signature);\n\n// Verify the signature\nconst address = '0xYourEthereumAddress';\nconst isValid = typed.verifyTyped(signature, typedData, address);\n\n// Recover the public key\nconst publicKey = typed.recoverPublicKeyTyped(signature, typedData);\n```\n\n## Network-related\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 APIs (chainlink, uniswap) expect instance of Web3Provider.\nThe call stack would look like this:\n\n- `Chainlink` =\u003e `Web3Provider` =\u003e `jsonrpc` =\u003e `fetch`\n\nTo initialize Web3Provider, do the following:\n\n```js\n// Requests are made with fetch(), a built-in method\nimport { jsonrpc } from 'micro-ftch';\nimport { Web3Provider } from 'micro-eth-signer/net';\nconst RPC_URL = 'http://localhost:8545';\nconst prov = new Web3Provider(jsonrpc(fetch, RPC_URL));\n\n// Example using mewapi RPC\nconst RPC_URL_2 = 'https://nodes.mewapi.io/rpc/eth';\nconst prov2 = new Web3Provider(\n  jsonrpc(fetch, RPC_URL_2, { Origin: 'https://www.myetherwallet.com' })\n);\n```\n\n### Fetch balances \u0026 history\n\n\u003e [!NOTE]\n\u003e Basic data can be fetched from any node.\n\u003e Uses `trace_filter` \u0026 requires [Erigon](https://erigon.tech), others are too slow.\n\n```ts\nconst addr = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';\nconst block = await prov.blockInfo(await prov.height());\nconsole.log('current block', block.number, block.timestamp, block.baseFeePerGas);\nconsole.log('info for addr', addr, await prov.unspent(addr));\n\n// Other methods of Web3Provider:\n// blockInfo(block: number): Promise\u003cBlockInfo\u003e; // {baseFeePerGas, hash, timestamp...}\n// height(): Promise\u003cnumber\u003e;\n// internalTransactions(address: string, opts?: TraceOpts): Promise\u003cany[]\u003e;\n// ethLogsSingle(topics: Topics, opts: LogOpts): Promise\u003cLog[]\u003e;\n// ethLogs(topics: Topics, opts?: LogOpts): Promise\u003cLog[]\u003e;\n// tokenTransfers(address: string, opts?: LogOpts): Promise\u003c[Log[], Log[]]\u003e;\n// wethTransfers(address: string, opts?: LogOpts): Promise\u003c[Log[]]\u003e;\n// txInfo(txHash: string, opts?: TxInfoOpts): Promise\u003c{\n//   type: \"legacy\" | \"eip2930\" | \"eip1559\" | \"eip4844\"; info: any; receipt: any; raw: string | undefined;\n// }\u003e;\n// tokenInfo(address: string): Promise\u003cTokenInfo | undefined\u003e;\n// transfers(address: string, opts?: TraceOpts \u0026 LogOpts): Promise\u003cTxTransfers[]\u003e;\n// allowances(address: string, opts?: LogOpts): Promise\u003cTxAllowances\u003e;\n// tokenBalances(address: string, tokens: string[]): Promise\u003cRecord\u003cstring, bigint\u003e\u003e;\n```\n\n### Fetch Chainlink oracle prices\n\n```ts\nimport { Chainlink } from 'micro-eth-signer/net';\nconst link = new Chainlink(prov);\nconst btc = await link.coinPrice('BTC');\nconst bat = await link.tokenPrice('BAT');\nconsole.log({ btc, bat }); // BTC 19188.68870991, BAT 0.39728989 in USD\n```\n\n### Resolve ENS address\n\n```ts\nimport { ENS } from 'micro-eth-signer/net';\nconst ens = new ENS(prov);\nconst vitalikAddr = await ens.nameToAddress('vitalik.eth');\n```\n\n### Swap tokens with Uniswap\n\n\u003e 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```ts\nimport { tokenFromSymbol } from 'micro-eth-signer/abi';\nimport { UniswapV3 } from 'micro-eth-signer/net'; // or UniswapV2\n\nconst USDT = tokenFromSymbol('USDT');\nconst BAT = tokenFromSymbol('BAT');\nconst u3 = new UniswapV3(prov); // or new UniswapV2(provider)\nconst fromAddress = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';\nconst toAddress = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';\nconst swap = await u3.swap(USDT, BAT, '12.12', { slippagePercent: 0.5, ttl: 30 * 60 });\nconst swapData = await swap.tx(fromAddress, toAddress);\nconsole.log(swapData.amount, swapData.expectedAmount, swapData.allowance);\n```\n\n## Advanced\n\n### Type-safe ABI parsing\n\nThe ABI is type-safe when `as const` is specified:\n\n```ts\nimport { createContract } from 'micro-eth-signer/abi';\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);\n// Would create following typescript type:\n{\n  getReserves: {\n    encodeInput: () =\u003e Uint8Array;\n    decodeOutput: (b: Uint8Array) =\u003e {\n      reserve0: bigint;\n      reserve1: bigint;\n      blockTimestampLast: bigint;\n    };\n  }\n}\n```\n\nWe're parsing values as:\n\n```js\n// no inputs\n{} -\u003e encodeInput();\n// single input\n{inputs: [{type: 'uint'}]} -\u003e encodeInput(bigint);\n// all inputs named\n{inputs: [{type: 'uint', name: 'lol'}, {type: 'address', name: 'wut'}]} -\u003e encodeInput({lol: bigint, wut: string})\n// at least one input is unnamed\n{inputs: [{type: 'uint', name: 'lol'}, {type: 'address'}]} -\u003e 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/ens.ts`](./src/net/ens.ts) for type-safe contract execution example.\n\n### Human-readable transaction hints\n\nThe transaction sent ERC-20 USDT token between addresses. The library produces a following hint:\n\n\u003e Transfer 22588 USDT to 0xdac17f958d2ee523a2206206994597c13d831ec7\n\n```ts\nimport { decodeTx } from 'micro-eth-signer/abi';\n\nconst tx =\n  '0xf8a901851d1a94a20082c12a94dac17f958d2ee523a2206206994597c13d831ec780b844a9059cbb000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000000000000000000000000000000000054259870025a066fcb560b50e577f6dc8c8b2e3019f760da78b4c04021382ba490c572a303a42a0078f5af8ac7e11caba9b7dc7a64f7bdc3b4ce1a6ab0a1246771d7cc3524a7200';\n// Decode tx information\ndeepStrictEqual(decodeTx(tx), {\n  name: 'transfer',\n  signature: 'transfer(address,uint256)',\n  value: {\n    to: '0xdac17f958d2ee523a2206206994597c13d831ec7',\n    value: 22588000000n,\n  },\n  hint: 'Transfer 22588 USDT to 0xdac17f958d2ee523a2206206994597c13d831ec7',\n});\n```\n\nOr if you have already decoded tx:\n\n```ts\nimport { decodeData } from 'micro-eth-signer/abi';\n\nconst to = '0x7a250d5630b4cf539739df2c5dacb4c659f2488d';\nconst data =\n  '7ff36ab5000000000000000000000000000000000000000000000000ab54a98ceb1f0ad30000000000000000000000000000000000000000000000000000000000000080000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045000000000000000000000000000000000000000000000000000000006fd9c6ea0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000106d3c66d22d2dd0446df23d7f5960752994d600';\nconst value = 100000000000000000n;\n\ndeepStrictEqual(decodeData(to, data, value, { customContracts }), {\n  name: 'swapExactETHForTokens',\n  signature: 'swapExactETHForTokens(uint256,address[],address,uint256)',\n  value: {\n    amountOutMin: 12345678901234567891n,\n    path: [\n      '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n      '0x106d3c66d22d2dd0446df23d7f5960752994d600',\n    ],\n    to: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',\n    deadline: 1876543210n,\n  },\n});\n\n// With custom tokens/contracts\nconst customContracts = {\n  '0x106d3c66d22d2dd0446df23d7f5960752994d600': { abi: 'ERC20', symbol: 'LABRA', decimals: 9 },\n};\ndeepStrictEqual(decodeData(to, data, value, { customContracts }), {\n  name: 'swapExactETHForTokens',\n  signature: 'swapExactETHForTokens(uint256,address[],address,uint256)',\n  value: {\n    amountOutMin: 12345678901234567891n,\n    path: [\n      '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n      '0x106d3c66d22d2dd0446df23d7f5960752994d600',\n    ],\n    to: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',\n    deadline: 1876543210n,\n  },\n  hint: 'Swap 0.1 ETH for at least 12345678901.234567891 LABRA. Expires at Tue, 19 Jun 2029 06:00:10 GMT',\n});\n```\n\n### Human-readable event hints\n\nDecoding the event produces the following hint:\n\n\u003e Allow 0xe592427a0aece92de3edee1f18e0157c05861564 spending up to 1000 BAT from 0xd8da6bf26964af9d7eed9e03e53415d37aa96045\n\n```ts\nimport { decodeEvent } from 'micro-eth-signer/abi';\n\nconst to = '0x0d8775f648430679a709e98d2b0cb6250d2887ef';\nconst topics = [\n  '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925',\n  '0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045',\n  '0x000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564',\n];\nconst data = '0x00000000000000000000000000000000000000000000003635c9adc5dea00000';\nconst einfo = decodeEvent(to, topics, data);\nconsole.log(einfo);\n```\n\n### RLP \u0026 SSZ\n\n[packed](https://github.com/paulmillr/micro-packed) allows us to implement\nRLP in just 100 lines of code, and SSZ in 1500 lines.\n\nSSZ includes [EIP-7495](https://eips.ethereum.org/EIPS/eip-7495) stable containers.\n\n```ts\nimport { RLP } from 'micro-eth-signer/rlp';\n// More RLP examples in test/rlp.test.js\nRLP.decode(RLP.encode('dog'));\n```\n\n```ts\nimport * as ssz from 'micro-eth-signer/ssz';\n// More SSZ examples in test/ssz.test.js\n```\n\n### KZG \u0026 Verkle\n\nAllows to create \u0026 verify KZG EIP-4844 proofs.\n\n```ts\nimport * as verkle from 'micro-eth-signer/verkle';\n\nimport { KZG } from 'micro-eth-signer/kzg';\n// 400kb, 4-sec init\nimport { trustedSetup } from '@paulmillr/trusted-setups';\n// 800kb, instant init\nimport { trustedSetup as fastSetup } from '@paulmillr/trusted-setups/fast.js';\n\n// More KZG \u0026 Verkle examples in\n// https://github.com/ethereumjs/ethereumjs-monorepo\n\nconst kzg = new KZG(trustedSetup);\n\n// Example blob and scalar\nconst blob = '0x1234567890abcdef'; // Add actual blob data\nconst z = '0x1'; // Add actual scalar\n\n// Compute and verify proof\nconst [proof, y] = kzg.computeProof(blob, z);\nconsole.log('Proof:', proof);\nconsole.log('Y:', y);\nconst commitment = '0x1234567890abcdef'; // Add actual commitment\nconst z = '0x1'; // Add actual scalar\n// const y = '0x2'; // Add actual y value\nconst proof = '0x3'; // Add actual proof\nconst isValid = kzg.verifyProof(commitment, z, y, proof);\nconsole.log('Is valid:', isValid);\n\n// Compute and verify blob proof\nconst blob = '0x1234567890abcdef'; // Add actual blob data\nconst commitment = '0x1'; // Add actual commitment\nconst proof = kzg.computeBlobProof(blob, commitment);\nconsole.log('Blob proof:', proof);\nconst isValidB = kzg.verifyBlobProof(blob, commitment, proof);\n```\n\n## Security\n\nYou can verify standalone built files using github CLI:\n\n    gh attestation verify --owner paulmillr micro-eth-signer.js\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 external network interface, conforming to `Web3Provider`\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 whole balance\n\nThere is a method `setWholeAmount` which allows to send whole account balance:\n\n```ts\nconst CURRENT_BALANCE = '1.7182050000017'; // in eth\nconst txSendingWholeBalance = unsignedTx.setWholeAmount(weieth.decode(CURRENT_BALANCE));\n```\n\nIt does two things:\n\n1. `amount = accountBalance - maxFeePerGas * gasLimit`\n2. `maxPriorityFeePerGas = maxFeePerGas`\n\nEvery eth block sets a fee for all its transactions, called base fee.\nmaxFeePerGas indicates how much gas user is able to spend in the worst case.\nIf the block's base fee is 5 gwei, while user is able to spend 10 gwei in maxFeePerGas,\nthe transaction would only consume 5 gwei. That means, base fee is unknown\nbefore the transaction is included in a block.\n\nBy setting priorityFee to maxFee, we make the process deterministic:\n`maxFee = 10, maxPriority = 10, baseFee = 5` would always spend 10 gwei.\nIn the end, the balance would become 0.\n\n\u003e [!WARNING]\n\u003e Using the method would decrease privacy of a transfer, because\n\u003e payments for services have specific amounts, and not _the whole amount_.\n\n## Performance\n\nTransaction signature matches `noble-curves` `sign()` speed,\nwhich means over 4000 times per second on an M2 mac.\n\nThe first call of `sign` will take 20ms+ due to noble-curves secp256k1 `utils.precompute`.\n\nTo run benchmarks, execute `npm run bench`.\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulmillr%2Fmicro-eth-signer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulmillr%2Fmicro-eth-signer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulmillr%2Fmicro-eth-signer/lists"}