Socket
Socket
Sign inDemoInstall

ethereumjs-account

Package Overview
Dependencies
32
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ethereumjs-account

Encoding, decoding and validation of Ethereum's Account schema


Version published
Weekly downloads
95K
decreased by-22.54%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

[2.0.0] - 2016-01-06

  • Improved documentation
  • Simplified getCode()
  • Added tests

Older releases:

  • 1.0.5 - 2015-11-27
  • 1.0.3 - 2015-09-24

Readme

Source

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 a new account object

  • data - an account can be initialized with either a buffer containing the RLP serialized account. Or an Array of buffers relating to each of the account Properties, listed in order below. For example:
var raw = [ 
  '0x02', //nonce
  '0x0384', //balance
  '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', //stateRoot
  '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'  //codeHash
  ];

var account = new Account(raw);

Or lastly an Object containing the Properties of the account:

var raw = {
  nonce: '',
  balance: '0x03e7',
  stateRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
  codeHash: '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
};

var account = new Account(raw);

For 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.

Account Properties

  • nonce - The account's nonce.
  • balance - The account's balance in wei.
  • 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.

account.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 storing the accounts.
  • cb - The callback.
account.setCode(trie, code, cb)

Stores the code in the trie.

  • trie - The trie storing the accounts.
  • 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.

Keywords

FAQs

Last updated on 06 Jan 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc