JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 93985
  • Score
    100M100P100Q14303F
  • License GPL-2.0

a help module for ethereum account schema

Package Exports

  • ethereumjs-account

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ethereumjs-account) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

SYNOPSIS

js-standard-style Gitter or #ethereumjs on freenode

Implements schema and functions relating to accounts stored ethereum's state Trie
NOTE: this is different from ethereumjs-accounts which should be used if you want to key management and web3 sugar.

INSTALL

npm install ethereumjs-account

BROWSER

This module work with browserify

API

new Account([data])

Creates an new account object

  • data - an account can be initiailized with either a buffer containing the RLP serialized account. Or an array of buffers relating to each of the tx Properties, listed in order below. For example.
var raw = [ 
  '02', //nonce
  '0384', //balance
  '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', //stateRoot
  'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'  //codeHash
  ];

var tx = new Account(raw);

Or lastly an Object containing the Properties of the transaction

var raw = {
  nonce: '',
  balance: '03e7',
  stateRoot: '56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
  codeHash: 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
};

var tx = new Account(raw);

For Object and Arrays each of the elements can either be a Buffer, hex String , Number, or an object with a toBuffer method such as Bignum.

Account Properties

  • nonce - The account's nonce.
  • balance - The account's balance in wie
  • stateRoot - the stateRoot for the storage of the contract
  • codeHash - the hash of the code of the contract

Account Methods

Account.isEmpty()

Returns a Boolean determining if the account is empty

account.isContract()

Returns a Boolean deteremining if the account is a contract

account.serialize()

Returns the RLP serialization of the account as a Buffer

acount.toJSON([object])

Returns the account as JSON

  • object - a Boolean that defaults to false. If object is true then this will return an object else it will return an array.

account.getCode(trie, cb)

Fetches the code from the trie

  • trie - the trie to storing the accounts
  • cb - the callback

account.setCode(trie, code, cb)

Stores the code in the trie

  • trie - the trie
  • code - a Buffer
  • cb - the callback

account.getStorage(trie, key, cb)

Fetches key from the account's storage

account.setStorage(trie, key, val, cb)

Stores a val at the key in the contract's storage