{"name":"ethereumjs-account","version":"3.0.0","description":"Encoding, decoding and validation of Ethereum's Account schema","main":"./dist/index.js","types":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/ethereumjs/ethereumjs-account.git"},"scripts":{"build":"tsc -p ./tsconfig.prod.json","prepublishOnly":"npm run test && npm run build","coverage":"nyc npm run test && nyc report --reporter=text-lcov > .nyc_output/lcov.info","coveralls":"npm run coverage && coveralls <.nyc_output/lcov.info","format":"prettier --list-different **/*.{ts,json,md}","format:fix":"prettier --write **/*.{ts,json,md}","tslint":"tslint -p ./tsconfig.json -e node_modules/**/* -e **/node_modules/**/* -e dist/**/* **/*.ts","tslint:fix":"tslint --fix --format stylish -p ./tsconfig.json -e node_modules/**/* -e **/node_modules/**/* -e dist/**/* **/*.ts","tsc":"tsc --noEmit","lint":"npm run format && npm run tslint && npm run tsc","lint:fix":"npm run format:fix && npm run tslint:fix && npm run tsc","test":"ts-node node_modules/tape/bin/tape ./test/index.ts"},"keywords":["ethereum","account"],"author":{"name":"mjbecze","url":"mjbecze@gmail.com"},"license":"MPL-2.0","bugs":{"url":"https://github.com/ethereumjs/ethereumjs-account/issues"},"homepage":"https://github.com/ethereumjs/ethereumjs-account#readme","dependencies":{"ethereumjs-util":"^6.0.0","rlp":"^2.2.1","safe-buffer":"^5.1.1"},"devDependencies":{"@ethereumjs/config-nyc":"^1.0.0","@ethereumjs/config-prettier":"^1.0.1","@ethereumjs/config-tsc":"^1.0.2","@ethereumjs/config-tslint":"^1.0.0","@types/bn.js":"^4.11.3","@types/node":"^10.12.18","@types/tape":"^4.2.33","coveralls":"^3.0.0","nyc":"^11.7.1","prettier":"^1.15.3","tape":"^4.0.3","ts-node":"^7.0.1","tslint":"^5.12.0","typescript":"^3.2.2","typestrict":"^1.0.2"},"gitHead":"f1b09614f082e28926e99f83ac10641b75b34609","_id":"ethereumjs-account@3.0.0","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"dist":{"integrity":"sha512-WP6BdscjiiPkQfF9PVfMcwx/rDvfZTjFKY0Uwc09zSQr9JfIVH87dYIJu0gNhBhpmovV4yq295fdllS925fnBA==","shasum":"728f060c8e0c6e87f1e987f751d3da25422570a9","tarball":"http://registry-npm.ywwl.com/ethereumjs-account/download/ethereumjs-account-3.0.0.tgz","fileCount":6,"unpackedSize":16383,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcPK45CRA9TVsSAnZWagAACmMP/3oORXGUPHXvYC9QUAbO\nV7eDriRKbC4BUQjnKCbSERMVsLBtxyGmic9ISoVqkoGwQsj4pGcVHbkawtnP\nGH58QFWUqIL+T06QmPLObimpO7BM5kJ9Nui+iJD7JYhgpesb6UkQHBvi6CjC\naraVnwCAYloyFSILGWD/EO3LmJd0xl1n9XWXZJeqwGy2Yvhkeg3IUcwCxChV\nLJ7pzPrlqLifXDStulkfrZinG/9l1PvTQJlJbgoDmBsijsAwFwRQbQwk8741\n42YCLOc1SS1qOUyfMnPWOxB2I74Q1snauSoopzx7xd8S5PVNxeZWnouIfWAt\n1YpyCd/q4FNIqRCWcaY9kqSr0qMsCDQaWy2i1nKy8sKoNB1GluVv3Qs2Cfui\n67ud75D+EXezFi8IwP1nwklbgr8p8hE24BcdujwqB0eNyHaWfOdDO/2wVP3a\nP6hvj7S4XF1SI3NPznvVSXxHNB8q8GtrwSNlYusWGzAXQade+3K6s7KWYZyH\nuOSFvJAzwZtWd52H11snBfS26QE3hV/cM2BrPgI7HedCIyxSastRM1sh2WJY\nqibyjVkPy/y3OxMHPsnYbKAUzTbigFnjNQIkHU4Tnt249qcxfbmNveJT7iGA\n0OXEXnuxZageFqwQ1GgyA2EfHsfCfOHASwuSPPNj1aUyY73AHV4zCmL6kX0s\nNkl7\r\n=MVzk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDfvphd+fa1chP/blQp/+vhFLZe1Ey4VMYU2i1okKOS9QIhANww/9wb80ap5bBtW9PapuOW9Wr2v/5gNeNuDXeMImPO"}],"size":5215,"noattachment":false,"key":"/ethereumjs-account/-/ethereumjs-account-3.0.0.tgz"},"maintainers":[{"email":"alex@rtfs.hu","name":"axic"},{"email":"Holger.Drewes@gmail.com","name":"holgerd77"},{"email":"j-wasinger@hotmail.com","name":"jwasinger"},{"email":"null_radix@riseup.net","name":"null_radix"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ethereumjs-account_3.0.0_1547480632795_0.9227583170979712"},"_hasShrinkwrap":false,"deprecated":"Please use Util.Account class found on package ethereumjs-util@^7.0.6 https://github.com/ethereumjs/ethereumjs-util/releases/tag/v7.0.6","readme":"# SYNOPSIS\n\n[![NPM Package](https://img.shields.io/npm/v/ethereumjs-account.svg?style=flat-square)](https://www.npmjs.org/package/ethereumjs-account)\n[![Build Status](https://travis-ci.org/ethereumjs/ethereumjs-account.svg?branch=master)](https://travis-ci.org/ethereumjs/ethereumjs-account)\n[![Coverage Status](https://img.shields.io/coveralls/ethereumjs/ethereumjs-account.svg?style=flat-square)](https://coveralls.io/r/ethereumjs/ethereumjs-account)\n[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)](https://gitter.im/ethereum/ethereumjs-lib)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n\nThis library eases the handling of Ethereum accounts, where accounts can be either external accounts\nor contracts (see\n[Account Types](http://ethdocs.org/en/latest/contracts-and-transactions/account-types-gas-and-transactions.html) docs).\n\nNote that the library is not meant to be used to handle your wallet accounts, use e.g. the\n[web3-eth-personal](http://web3js.readthedocs.io/en/1.0/web3-eth-personal.html) package from the\n`web3.js` library for that. This is just a semantic wrapper to ease the use of account data and\nprovide functionality for reading and writing accounts from and to the Ethereum state trie.\n\n# INSTALL\n\n`npm install ethereumjs-account`\n\n# BROWSER\n\nThis module work with `browserify`.\n\n# API\n\n- [`new Account([data])`](#new-accountdata)\n- [`Account` Properties](#account-properties)\n- [`Account` Methods](#account-methods)\n  - [`account.isEmpty()`](#accountisempty)\n  - [`account.isContract()`](#accountiscontract)\n  - [`account.serialize()`](#accountserialize)\n  - [`account.toJSON()`](#accounttojson)\n  - [`account.getCode(trie, cb)`](#accountgetcodetrie-cb)\n  - [`account.setCode(trie, code, cb)`](#accountsetcodetrie-code-cb)\n  - [`account.getStorage(trie, key, cb)`](#accountgetstoragetrie-key-cb)\n  - [`account.setStorage(trie, key, val, cb)`](#accountsetstoragetrie-key-val-cb)\n\n### `new Account([data])`\n\nCreates a new account object\n\n- `data` - an account can be initialized with either a `buffer` containing the RLP serialized account.\n  Or an `Array` of buffers relating to each of the account Properties, listed in order below. For example:\n\n```javascript\nvar raw = [\n  '0x02', //nonce\n  '0x0384', //balance\n  '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', //stateRoot\n  '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470', //codeHash\n]\n\nvar account = new Account(raw)\n```\n\nOr lastly an `Object` containing the Properties of the account:\n\n```javascript\nvar raw = {\n  nonce: '',\n  balance: '0x03e7',\n  stateRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',\n  codeHash: '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470',\n}\n\nvar account = new Account(raw)\n```\n\nFor `Object` and `Array` each of the elements can either be a `Buffer`, hex `String`, `Number`, or an object with a `toBuffer` method such as `Bignum`.\n\n### `Account` Properties\n\n- `nonce` - The account's nonce.\n- `balance` - The account's balance in wei.\n- `stateRoot` - The stateRoot for the storage of the contract.\n- `codeHash` - The hash of the code of the contract.\n\n### `Account` Methods\n\n#### `account.isEmpty()`\n\nReturns a `Boolean` determining if the account is empty.\n\n#### `account.isContract()`\n\nReturns a `Boolean` deteremining if the account is a contract.\n\n#### `account.serialize()`\n\nReturns the RLP serialization of the account as a `Buffer`.\n\n#### `account.toJSON([object])`\n\nReturns the account as JSON.\n\n- `object` - A `Boolean` that defaults to false. If `object` is true then this will return an `Object`, else it will return an `Array`.\n\n#### `account.getCode(trie, cb)`\n\nFetches the code from the trie.\n\n- `trie` - The [trie](https://github.com/ethereumjs/merkle-patricia-tree) storing the accounts.\n- `cb` - The callback.\n\n#### `account.setCode(trie, code, cb)`\n\nStores the code in the trie.\n\n- `trie` - The [trie](https://github.com/ethereumjs/merkle-patricia-tree) storing the accounts.\n- `code` - A `Buffer`.\n- `cb` - The callback.\n\nExample for `getCode` and `setCode`:\n\n```javascript\n// Requires manual merkle-patricia-tree install\nconst SecureTrie = require('merkle-patricia-tree/secure')\nconst Account = require('./index.js').default\n\nlet code = Buffer.from(\n  '73095e7baea6a6c7c4c2dfeb977efac326af552d873173095e7baea6a6c7c4c2dfeb977efac326af552d873157',\n  'hex',\n)\n\nlet raw = {\n  nonce: '',\n  balance: '0x03e7',\n  stateRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',\n  codeHash: '0xb30fb32201fe0486606ad451e1a61e2ae1748343cd3d411ed992ffcc0774edd4',\n}\n\nlet account = new Account(raw)\nlet trie = new SecureTrie()\n\naccount.setCode(trie, code, function(err, codeHash) {\n  console.log(`Code with hash 0x${codeHash.toString('hex')} set to trie`)\n  account.getCode(trie, function(err, code) {\n    console.log(`Code ${code.toString('hex')} read from trie`)\n  })\n})\n```\n\n#### `account.getStorage(trie, key, cb)`\n\nFetches `key` from the account's storage.\n\n#### `account.setStorage(trie, key, val, cb)`\n\nStores a `val` at the `key` in the contract's storage.\n\nExample for `getStorage` and `setStorage`:\n\n```javascript\n// Requires manual merkle-patricia-tree install\nconst SecureTrie = require('merkle-patricia-tree/secure')\nconst Account = require('./index.js').default\n\nlet raw = {\n  nonce: '',\n  balance: '0x03e7',\n  stateRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',\n  codeHash: '0xb30fb32201fe0486606ad451e1a61e2ae1748343cd3d411ed992ffcc0774edd4',\n}\n\nlet account = new Account(raw)\nlet trie = new SecureTrie()\n\nlet key = Buffer.from('0000000000000000000000000000000000000000', 'hex')\nlet value = Buffer.from('01', 'hex')\n\naccount.setStorage(trie, key, value, function(err, value) {\n  account.getStorage(trie, key, function(err, value) {\n    console.log(`Value ${value.toString('hex')} set and retrieved from trie.`)\n  })\n})\n```\n","publish_time":1547480632923,"_cnpm_publish_time":1547480632923,"dist-tags":{"latest":"3.0.0"}}