var Account = module.exports = function (data) {
  // Define Properties
  var fields = [{
    name: 'nonce',
    default: new Buffer([])
  }, {
    name: 'balance',
    default: new Buffer([])
  }, {
    name: 'stateRoot',
    length: 32,
    default: ethUtil.SHA3_RLP
  }, {
    name: 'codeHash',
    length: 32,
    default: ethUtil.SHA3_NULL
  }]

  ethUtil.defineProperties(this, fields, data)
}
Example #2
0
var Transaction = module.exports = function(data) {
  var self = this
  //Define Properties
  const fields = [{
    name: 'nonce',
    word: true,
    noZero: true,
    default: new Buffer([])
  }, {
    name: 'gasPrice',
    word: true,
    default: new Buffer([])
  }, {
    name: 'gasLimit',
    word: true,
    default: new Buffer([])
  }, {
    name: 'to',
    empty: true,
    length: 20,
    default: new Buffer([])
  }, {
    name: 'value',
    empty: true,
    word: true,
    noZero: true,
    default: new Buffer([])
  }, {
    name: 'data',
    empty: true,
    default: new Buffer([0])
  }, {
    name: 'v',
    length: 1,
    default: new Buffer([0x1c])
  }, {
    name: 'r',
    pad: true,
    length: 32,
    default: ethUtil.zeros(32)
  }, {
    name: 's',
    pad: true,
    length: 32,
    default: ethUtil.zeros(32)
  }]

  Object.defineProperty(this, 'from', {
    enumerable: false,
    configurable: true,
    get: function() {
      if(this._from) 
        return this._from
      return this._from = this.getSenderAddress()
    },
    set: function(v) {
      this._from = v
    }
  })

  ethUtil.defineProperties(this, fields, data)
}
Example #3
0
    const Transaction = function (data) {
    // Define Properties
    const fields = [{
        name: 'nonce',
        length: 32,
        allowLess: true,
        default: new Buffer([])
    }, {
        name: 'gasPrice',
        length: 32,
        allowLess: true,
        default: new Buffer([])
    }, {
        name: 'gasLimit',
        alias: 'gas',
        length: 32,
        allowLess: true,
        default: new Buffer([])
    }, {
        name: 'to',
        allowZero: true,
        length: 20,
        default: new Buffer([])
    }, {
        name: 'value',
        length: 32,
        allowLess: true,
        default: new Buffer([])
    }, {
        name: 'data',
        alias: 'input',
        allowZero: true,
        default: new Buffer([])
    }, {
        name: 'v',
        length: 1,
        default: new Buffer([0x1c])
    }, {
        name: 'r',
        length: 32,
        allowLess: true,
        default: new Buffer([])
    }, {
        name: 's',
        length: 32,
        allowLess: true,
        default: new Buffer([])
    }]

    /**
     * Returns the rlp encoding of the transaction
     * @method serialize
     * @return {Buffer}
     */
    // attached serialize
    ethUtil.defineProperties(this, fields, data)

    /**
     * @prop {Buffer} from (read only) sender address of this transaction, mathematically derived from other parameters.
     */
    Object.defineProperty(this, 'from', {
        enumerable: true,
        configurable: true,
        get: this.getSenderAddress.bind(this)
    })

    this._homestead = true
    }