{"id":18738088,"url":"https://github.com/blocknative/ethereum-input-to-object","last_synced_at":"2025-04-12T19:32:45.684Z","repository":{"id":40759964,"uuid":"274021894","full_name":"blocknative/ethereum-input-to-object","owner":"blocknative","description":"Decodes an Ethereum input data hex string into a developer friendly JavaScript object","archived":false,"fork":false,"pushed_at":"2023-01-07T19:49:54.000Z","size":1195,"stargazers_count":28,"open_issues_count":14,"forks_count":8,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-26T14:07:23.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blocknative.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-22T02:29:06.000Z","updated_at":"2024-04-30T03:02:24.000Z","dependencies_parsed_at":"2023-02-07T23:31:38.082Z","dependency_job_id":null,"html_url":"https://github.com/blocknative/ethereum-input-to-object","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocknative%2Fethereum-input-to-object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocknative%2Fethereum-input-to-object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocknative%2Fethereum-input-to-object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocknative%2Fethereum-input-to-object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blocknative","download_url":"https://codeload.github.com/blocknative/ethereum-input-to-object/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248621382,"owners_count":21134829,"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":[],"created_at":"2024-11-07T15:28:07.835Z","updated_at":"2025-04-12T19:32:45.113Z","avatar_url":"https://github.com/blocknative.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ethereum-input-to-object\n\nDecodes an Ethereum input data hex string into a developer friendly JavaScript object.\n\n## Warning\n\nThis package is in alpha, use at your own risk!\n\n## Aim\n\nThe goal of ethereum-input-to-object is to facilitate dead-simple conversion of a transaction input into a JavaScript native, serializable object.\n\n## Usage\n\n### Simple example\n\nPass an ABI and input to `inputToObject`\n\n```javascript\nimport inputToObject from 'ethereum-input-to-object';\nconst erc20Abi = [{ ... }];\nconst input = '0xa9059cbb0000000000000000000000005a1cb5a88988ca4fef229935db834a6781e873cb0000000000000000000000000000000000000000000000000de0b6b3a7640000';\nconst decoded = inputToObject(erc20Abi, input);\nconsole.log(decoded);\n```\n\n```javascript\n{\n  methodName: 'transfer',\n  params: {\n    _to: '0x5A1Cb5A88988cA4FEF229935db834A6781e873cB',\n    _value: '1000000000000000000'\n  }\n}\n```\n\n### Unable to decode example\n\nIf the input does not match the ABI, `inputToObject` returns `null`\n\n```javascript\nimport inputToObject from 'ethereum-input-to-object';\nconst erc20Abi = [{ ... }];\nconst input = '0xgarbage';\nconst decoded = inputToObject(erc20Abi, input);\nconsole.log(decoded);\n```\n\n```javascript\nnull\n```\n\n### Complex example\n\n`inputToObject` also supports decoding and conversion of complex, nested Solidity data structures.\n\n```javascript\nimport inputToObject from 'ethereum-input-to-object';\nconst setProtocolRebalancingExchangeIssuanceV2Abi = [{ ... }];\nconst input = '0x16919b9...'; // Truncated for example\nconst decoded = inputToObject(erc20Abi, input);\nconsole.log(decoded);\n```\n\n```javascript\n{\n  methodName: 'issueRebalancingSetWithEther',\n  params: {\n    _rebalancingSetAddress: '0x81c55017F7Ce6E72451cEd49FF7bAB1e3DF64d0C',\n    _rebalancingSetQuantity: '2810697751873000000',\n    _exchangeIssuanceParams: {\n      setAddress: '0xA37dE6790861B5541b0dAa7d0C0e651F44c6f4D9',\n      quantity: '16878240000000000',\n      sendTokenExchangeIds: ['1'],\n      sendTokens: ['0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'],\n      sendTokenAmounts: ['1874799564199638103'],\n      receiveTokens: ['0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359', '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'],\n      receiveTokenAmounts: ['121675511211317568000', '1687824'],\n    },\n    _orderData: '0x000000000000000000000000...', // Truncated for example\n    _keepChangeInVault: true,\n  }\n}\n```\n\n### Decoder param example\n\nIf you prefer, you may pass a `decoder` created using [ethereum-input-data-decoder](https://github.com/miguelmota/ethereum-input-data-decoder) instead of an ABI as the first parameter\n\n```javascript\nimport InputDataDecoder from 'ethereum-input-data-decoder';\nimport inputToObject from 'ethereum-input-to-object';\nconst erc20Abi = [{ ... }];\nconst erc20Decoder = new InputDataDecoder(erc20Abi);\nconst input = '0xa9059cbb0000000000000000000000005a1cb5a88988ca4fef229935db834a6781e873cb0000000000000000000000000000000000000000000000000de0b6b3a7640000';\nconst decoded = inputToObject(erc20Decoder, input);\n```\n\n### Usage in node.js\n\nWhen ES6 imports are not avaliable, you may use `require`\n\n```javascript\nconst inputToObject = require('ethereum-input-to-object')\n```\n\n### Supported types\n\n| Solidity | JavaScript equivalent used\n|------|--------|\n| int (all variations) | String\n| address | String\n| string | String\n| bool | Boolean\n| bytes (all variations) | String (hex formatted)\n| tuple | Object (with contents also converted)\n| array | Array (with contents also converted)\n\nUsing a type not supported? Open an issue.\n\n## ethereum-input-data-decoder\n\nThis library is built on the great work by Miguel on [ethereum-input-data-decoder](https://github.com/miguelmota/ethereum-input-data-decoder).\n\nIf ethereum-input-to-object prioritises convenience over function too much for you, check out his project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblocknative%2Fethereum-input-to-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblocknative%2Fethereum-input-to-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblocknative%2Fethereum-input-to-object/lists"}