{"_id":"@alexastrabit/abi-coder","name":"@alexastrabit/abi-coder","dist-tags":{"latest":"5.0.0"},"versions":{"5.0.0":{"name":"@alexastrabit/abi-coder","version":"5.0.0","description":"ABI function, event, and contrustor encoder/decoder","author":{"name":"Timur Badretdinov","email":"destinerx@gmail.com"},"keywords":["abi","ethers","ethereum"],"license":"MIT","repository":{"type":"git","url":"git://github.com/Destiner/abi-coder.git"},"type":"commonjs","main":"./lib/index.js","exports":"./lib/index.js","scripts":{"test":"vitest run","lint":"npm run lint:eslint && npm run lint:prettier","lint:eslint":"eslint \"{src,test}/**/*.ts\"","lint:prettier":"prettier -c \"{src,test}/**/*.{json,js,ts}\"","build":"tsc --p tsconfig.build.json","prepack":"npm run build"},"devDependencies":{"@types/node":"20.8.10","@typescript-eslint/eslint-plugin":"^6.5.0","eslint":"8.52.0","eslint-import-resolver-typescript":"3.6.1","eslint-plugin-import":"2.28.1","eslint-plugin-prettier":"5.0.1","prettier":"3.0.3","ts-node":"10.9.1","typescript":"5.2.2","vitest":"^0.34.6"},"peerDependencies":{"ethers":"^6.0.0"},"types":"./lib/index.d.ts","gitHead":"283babc015ff239f25fd4a8c824e8b32b943626f","bugs":{"url":"https://github.com/Destiner/abi-coder/issues"},"homepage":"https://github.com/Destiner/abi-coder#readme","_id":"@alexastrabit/abi-coder@5.0.0","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-NdFRH+ulaz//BOgSICHsTsBEDjWDC7xAkX5w+UKh5SdkRwHYc8RA6Gqm5jTs1YzLOhXqpzYZ1nH1go7/OvbbmQ==","shasum":"facce6c64b816652a54a53da0c5a5aa0de744cc7","tarball":"https://registry.npmjs.org/@alexastrabit/abi-coder/-/abi-coder-5.0.0.tgz","fileCount":7,"unpackedSize":29593,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID6RT9z9Mpn1D0fEr325EBNHHhKvE6SP+iuWSmF0OfQnAiAe6OsVhDRvajWQJTE18KOwWLVJABopJ3G8WfkGyj6owg=="}]},"_npmUser":{"name":"alexastrabit","email":"alexander@astrabit.io"},"directories":{},"maintainers":[{"name":"alexastrabit","email":"alexander@astrabit.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/abi-coder_5.0.0_1701336717723_0.0022078105781904167"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-30T09:31:57.626Z","5.0.0":"2023-11-30T09:31:57.940Z","modified":"2023-11-30T09:31:58.213Z"},"maintainers":[{"name":"alexastrabit","email":"alexander@astrabit.io"}],"description":"ABI function, event, and contrustor encoder/decoder","homepage":"https://github.com/Destiner/abi-coder#readme","keywords":["abi","ethers","ethereum"],"repository":{"type":"git","url":"git://github.com/Destiner/abi-coder.git"},"author":{"name":"Timur Badretdinov","email":"destinerx@gmail.com"},"bugs":{"url":"https://github.com/Destiner/abi-coder/issues"},"license":"MIT","readme":"# ABI Coder\n\nA set of high-level ABI encoding and decoding utils.\n\n## Motivation\n\nThere are several packages that provide ABI coding utils. However, there is no a high-level solution in the Ethers ecosystem. `web3-eth-abi` and `abi-decoder` depend on web3.js. `@ethersproject/abi` is pretty low-level. `ethereumjs-abi` works only with functions. Many other packages provide encoding or decoding only.\n\n## Features\n\n- Function coding\n- Event coding\n- Constructor coding\n- TS support\n\n## Installation\n\n`npm install abi-coder`\n\n> This package requires ethers V6. If you use ethers V5, you need to install abi-coder V4.\n\n> This package is a pure ESM package. Follow [this guide](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) for more info.\n\n## Example\n\n```ts\nimport { Coder } from 'abi-coder';\n\nimport * as erc20Abi from './abi/erc20.json';\n\nconst erc20Coder = new Coder(erc20Abi);\n\nerc20Coder.getFunctionSelector('totalSupply');\n// 0x18160ddd\n\nerc20Coder.decodeEvent(\n  [\n    '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n    '0x000000000000000000000000b5cfcb4d4745cbbd252945856e1b6eaadcf2fc4e',\n    '0x000000000000000000000000694c6aea9444876d4fa9375fc9089c370f8e9eda',\n  ],\n  '0x0000000000000000000000000000000000000000000000370c9b5ef669c35300',\n);\n/*\n{\n\tname: 'Transfer',\n\tinputs: [...],\n\tvalues: [\n\t\t'0xb5CFcb4D4745cBBD252945856E1B6eaadCf2fC4E',\n\t\t'0x694c6aea9444876d4fA9375fC9089C370F8E9edA',\n\t\tBigNumber('1015479348216300000000'),\n\t],\n}\n*/\n\nerc20Coder.encodeFunction({\n  name: 'transfer',\n  inputs: [\n    {\n      name: 'from',\n      type: 'address',\n    },\n    {\n      name: 'amount',\n      type: 'uint256',\n    },\n  ],\n  values: [\n    '0x694c6aea9444876d4fA9375fC9089C370F8E9edA',\n    '1015479348216300000000',\n  ],\n});\n// '0xa9059cbb000000000000000000000000694c6aea9444876d4fa9375fc9089c370f8e9eda0000000000000000000000000000000000000000000000370c9b5ef669c35300'\n```\n\n## API\n\n- Coder(abi)\n  - utils\n    - getFunctionSelector(name: string): string\n    - getEventTopic(name: string): string\n  - decoding\n    - decodeConstructor(data: string): Constructor\n    - decodeEvent(topics: string[], data: string): Event\n    - decodeFunction(data: string): FunctionData\n    - decodeFunctionOutput(name: string, data: string): FunctionOutputData\n  - encoding\n    - encodeConstructor(constructorData: Constructor): string\n    - encodeEvent(eventData: Event): EventEncoding\n    - encodeFunction(functionData: FunctionData): string\n    - encodeFunctionOutput(functionData: FunctionOutputData): string\n","readmeFilename":"README.md"}