{"_id":"@3test/ethereum-utils","_rev":"1-47c1e403675e3b7df6811b072e4a3d7d","name":"@3test/ethereum-utils","dist-tags":{"latest":"1.2.0"},"versions":{"1.2.0":{"name":"@3test/ethereum-utils","version":"1.2.0","description":"General Ethereum utility module with helper functions for the Ethereum blockchain.","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"npm run clean && npx tsc","clean":"rm -Rf ./dist","lint":"npx tslint 'src/**/*.ts?(x)'","test":"npm run lint && npx nyc npx hayspec test"},"hayspec":{"require":["ts-node/register"],"match":["./src/tests/**/*.test.ts"]},"nyc":{"extension":[".ts"],"require":["ts-node/register"],"exclude":["src/tests"]},"repository":{"type":"git","url":"git+https://github.com/0xcert/framework.git"},"bugs":{"url":"https://github.com/0xcert/framework/issues"},"homepage":"https://github.com/0xcert/framework#readme","keywords":["0xcert","framework","protocol","asset","value","values","currency","token","non-fungible","fungible","erc-721","erc-20","blockchain","javascript","typescript","nodejs","vuejs","nuxtjs","npm","libraries","smart-contract","ethereum","zxc"],"license":"MIT","devDependencies":{"@hayspec/cli":"^0.8.3","@hayspec/spec":"^0.8.3","ts-node":"^7.0.1","tslint":"^5.12.1","typescript":"^3.1.1"},"dependencies":{"ethers":"4.0.0-beta.1"},"_id":"@3test/ethereum-utils@1.2.0","_npmVersion":"6.4.1","_nodeVersion":"11.1.0","_npmUser":{"name":"moman","email":"vengust.tadej@gmail.com"},"dist":{"integrity":"sha512-F7tTwoWA0o/smST1uJwtP3H8k4YnEWc7ifDPL+CCqb1NE4yqLWcRYkdqhvcZX9nCGXtEouQH0g4bjqr6eaYmdA==","shasum":"41617e607300e0bbfd30015654855bfd216b9012","tarball":"https://registry.npmjs.org/@3test/ethereum-utils/-/ethereum-utils-1.2.0.tgz","fileCount":40,"unpackedSize":31624,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcrdShCRA9TVsSAnZWagAAP0AP+wUKWd1yx8ti8donKLAi\nfiObMA2xV1fbdUr9NmS3aDWJz8tyybg00mjnVFnldyFSL1awMUazdbKqoLIU\ncue1Vjh8229FJvjnjw9n68Yact0ssXalOMaiM2FbzuVWfyqJ7f+UIASIjMpA\n9OTR9fmzmCuWSh4MLSjp5W4k+OhGhuMHs6XxsXwZtpW5pBa4dRNGd15+0VZ7\nQ3ZlpXL2huv18Ym2nG5aENlwGZ9NsvWbx6t6gn1FfNdvsNgoOdd7JvurTQF5\ntdJ4Jol1RnvjckDI+jSMNonBAYuA3yfL288bbAUajxZdVi4hnpJU/TtSPqCx\ndoFixImHEJuxRIFJFuVT+l4fp5RC2gEF+gPM1vohYcg6ltk1aP7zcpe+vBSL\nGHO7deaXFw/mmKuezRv9hJXuk6dlRC9chJutVY+QrElUBO7WLE7FNBIZFcuM\nQfrfO7Hzy7DN3YsFv7heHBYm+BdPp/RoUbQjfukFneXvcvqUupYmFmhF38KT\nXLy7BUMyY8gballum5iFMrVKGwMoUoqjQA2K2cTa+zJHXPRqAr7EVnXYdfbV\naIvc9HfxckseQX2oalnDtkq+Le/PWKukv5PugY3yD9a6H/BvBrUKYKtE7Dqm\nh9akSE8MX0S9xRTX+JkCqoVvICFdyML95UmFeHjM1jBeC3Ur55qkwDKS3xeI\nnXtx\r\n=ldxB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCm0THqb2uPfTH1U7uhkYs4ZrRgdc1YOvlAqGDglwJ3XAIgD0nMANrcX67fAJAlwMLjLs6MwEW2z9BTpCHu8Xe1gKo="}]},"maintainers":[{"name":"moman","email":"vengust.tadej@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ethereum-utils_1.2.0_1554896032633_0.26889454838452864"},"_hasShrinkwrap":false}},"time":{"created":"2019-04-10T11:33:52.450Z","1.2.0":"2019-04-10T11:33:52.770Z","modified":"2022-04-04T10:45:25.818Z"},"maintainers":[{"name":"moman","email":"vengust.tadej@gmail.com"}],"description":"General Ethereum utility module with helper functions for the Ethereum blockchain.","homepage":"https://github.com/0xcert/framework#readme","keywords":["0xcert","framework","protocol","asset","value","values","currency","token","non-fungible","fungible","erc-721","erc-20","blockchain","javascript","typescript","nodejs","vuejs","nuxtjs","npm","libraries","smart-contract","ethereum","zxc"],"repository":{"type":"git","url":"git+https://github.com/0xcert/framework.git"},"bugs":{"url":"https://github.com/0xcert/framework/issues"},"license":"MIT","readme":"<img src=\"https://github.com/0xcert/framework/raw/master/assets/cover-sub.png\" />\n\n> General Ethereum utility module with helper functions for the Ethereum blockchain.\n\nThe [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.\n\nThis module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).\n\n# Ethereum Utilities\n\nThis module wraps several useful Ethereum functions which will be useful through the 0xcert Framework. Currently supported are these functions and classes from [ethers.js](https://github.com/ethers-io/ethers.js):\n\n## ABI coder\n\nThis converts value to and from the packed [Ethereum ABI encoding](https://solidity.readthedocs.io/en/develop/abi-spec.html#formal-specification-of-the-encoding).\n\n* `encodeParameters`(types: `any`, values: `Array<any>`): `string`\n* `decodeParameters`(types: `any`, data: `any`): `any`\n\n**Encoding example:**\n\n```ts\nimport { decodeParameters, encodeParameters } from '0xcert/ethereum-utils/abi';\n\nconst types = ['tuple(uint256, uint256[])'];\nconst values = [[ 42, [ 45 ] ]];\nconst encodedValues = encodeParameters(types, values);\n```\n\n**Decoding example:**\n\n```ts\nimport { decodeParameters, encodeParameters } from '0xcert/ethereum-utils/abi';\n\nconst types = ['tuple(uint256, uint256[])'];\nconst encoded = '0x' +\n  '0000000000000000000000000000000000000000000000000000000000000020' +\n  '000000000000000000000000000000000000000000000000000000000000002a' +\n  '0000000000000000000000000000000000000000000000000000000000000040' +\n  '0000000000000000000000000000000000000000000000000000000000000001' +\n  '000000000000000000000000000000000000000000000000000000000000002d';\nconst values = decodeParameters(types, values);\n```\n\n## BigNumber and bigNumberify\n\nHere is a basic example adapted from [the ethers.js documentation](https://docs.ethers.io/ethers.js/html/api-utils.html?highlight=bignumberify#big-numbers).\n\n```ts\nimport { BigNumber, bigNumberify } from '0xcert/ethereum-utils/big-number';\n\nlet gasPriceWei = bigNumberify(\"20902747399\");\nlet gasLimit = bigNumberify(3000000);\n\nlet maxCostWei = gasPriceWei.mul(gasLimit)\nconsole.log(\"Max Cost: \" + maxCostWei.toString());\n// \"Max Cost: 62708242197000000\"\n\nconsole.log(\"Number: \" + maxCostWei.toNumber());\n// throws an Error, the value is too large for JavaScript to handle safely\n```\n\n## Address normalization\n\nThe ethers.js [address normalization function](https://docs.ethers.io/ethers.js/html/api-utils.html?highlight=getaddress#addresses) implements [EIP-55 Mixed-case checksum address encoding](https://eips.ethereum.org/EIPS/eip-55).\n\n\n```ts\nimport { getAddress } from '0xcert/ethereum-utils/normalize-address';\n\nlet zxcTokenAddress = '0x83e2be8d114f9661221384b3a50d24b96a5653f5';\nlet zxcTokenAddressNormalized = normalizeAddress(zxcToenAddress);\n// 0x83e2BE8d114F9661221384B3a50d24B96a5653F5\n```","readmeFilename":"README.md"}