{"name":"ethereumjs-account","version":"2.0.5","description":"Encoding, decoding and validation of Ethereum's Account schema","main":"index.js","repository":{"type":"git","url":"git+https://github.com/ethereumjs/ethereumjs-account.git"},"scripts":{"coverage":"nyc npm run test && nyc report --reporter=text-lcov > .nyc_output/lcov.info","coveralls":"npm run coverage && coveralls <.nyc_output/lcov.info","lint":"standard","test":"tape ./test/index.js"},"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":"^5.0.0","rlp":"^2.0.0","safe-buffer":"^5.1.1"},"devDependencies":{"coveralls":"^3.0.0","nyc":"^11.7.1","standard":"^11.0.1","tape":"^4.0.3"},"gitHead":"bcd7207621728ddad9d6487623a7fa37d76b2df8","_id":"ethereumjs-account@2.0.5","_npmVersion":"5.6.0","_nodeVersion":"8.4.0","_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"dist":{"integrity":"sha512-bgDojnXGjhMwo6eXQC0bY6UK2liSFUSMwwylOmQvZbSl/D7NXQ3+vrGO46ZeOgjGfxXmgIeVNDIiHw7fNZM4VA==","shasum":"eeafc62de544cb07b0ee44b10f572c9c49e00a84","tarball":"http://registry-npm.ywwl.com/ethereumjs-account/download/ethereumjs-account-2.0.5.tgz","fileCount":6,"unpackedSize":14605,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa8VJqCRA9TVsSAnZWagAAyooP/j6GZgJfOLmAK9BACUEV\n0zkR4Ju3IcN1cPuCRgiFfoITMHxr8uZLxF1DR3gLyJPWKUD+8bqcr7F9tRyo\npIay4GDUWBzNK1aHoXxrtqSaClM3+aHxCRIlwiFlZGmjHFe5zSUVJWXNZemS\n5mJ+Mfw+RJK4e1+xZDN79iXPHAbwnttjqC/WlQt6fzCR2D1swOowaXH3hel4\nflBAYbY4jCXxMRdtO/quBHpFQ+va7OXvmcymYY6IDv871ONKLIlLS5CsEdpA\nEv60roawSZMaOjHVteenxz/BeEdvy0YXaL4p+qi8rVUFyJZqw6Qy68dOfnc5\nMW8xnoyqQ5gZdIePuBVYIFG6I9U7OLaIg31DVHASln9ivq+c0fSG6EOoT1mM\nz9TOjQWdCUuvbwA9mbHMCy4yi8gNRPmDXHAfPjE9vtUz5zJ9qIIxRrTI6sdL\n1iye+VyJIvZIJVXMjAAo6Fm5OWuEaRC5qJ34VWfN3e9hZBLqE/bq//g7kNzc\nHC2Qo+L62I0H3zLN1EEkJpjGCwgM1crgIYvGL8Cxqu6kPuSpBudQD45tjLLo\nqm3LMYZcBdgiTGIl/6dESNNDMiNvJXZKKTW2254DQcs19viT283WEUf8E1cx\n+9zo4shqlEraa2xmxttjDZ2olQOMrfFLNI8oDQGMTrTuGRdmoIc6ps7tMnQG\nVvT3\r\n=Rip5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC/zWB+8Hx5Q4JtnwD8DKzvrBTtwYfZaE84Aff6lsgxowIgPWFCmQqjjz9JWRvcMA5QG9hmVkFJbp3iqx2Yz/426To="}],"size":4169,"noattachment":false,"key":"/ethereumjs-account/-/ethereumjs-account-2.0.5.tgz"},"maintainers":[{"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_2.0.5_1525764713532_0.6601289991986645"},"_hasShrinkwrap":false,"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":1525764713594,"_cnpm_publish_time":1525764713594,"dist-tags":{"latest":"3.0.0"}}