dist/index.common.js
function buildTransaction(privateKeyHex, toAddress, hash, web3) {
  var privateKeyBuffer = Buffer.from(privateKeyHex, 'hex');

  if (!EthereumUtil.isValidPrivate(privateKeyBuffer)) {
    throw new Error('Invalid private key.');
  }

  var txParams = {
    nonce: '0x00',
    gasPrice: '0x09184e72a000', // How should we set this?
    gasLimit: '0x5A88',
    to: EthereumUtil.addHexPrefix(toAddress),
    value: '0x00',
    data: EthereumUtil.addHexPrefix(hash)
  };

  if (web3 !== undefined) {
    var gas = web3.eth.estimateGas(txParams);
    var nonce = web3.eth.getTransactionCount(
      EthereumUtil.bufferToHex(
        EthereumUtil.privateToAddress(privateKeyBuffer)
      ));
    txParams.gasLimit = web3.toHex(gas);
    txParams.nonce = web3.toHex(nonce);
    txParams.gasPrice = web3.toHex(web3.eth.gasPrice);
  }

  var tx = new EthereumTx(txParams);

  tx.sign(privateKeyBuffer);
  return tx;
}
function buildTransaction(privateKeyHex, toAddress, hash, web3) {
  var privateKeyBuffer = Buffer.from(privateKeyHex, 'hex');

  if (!EthereumUtil.isValidPrivate(privateKeyBuffer)) {
    throw new Error('Invalid private key.');
  }

  var txParams = {
    nonce: '0x00',
    gasPrice: '0x09184e72a000', // How should we set this?
    gasLimit: '0x5A88',
    to: EthereumUtil.addHexPrefix(toAddress),
    value: '0x00',
    data: EthereumUtil.addHexPrefix(hash)
  };

  if (web3 !== undefined) {
    var gas = web3.eth.estimateGas(txParams);
    var nonce = web3.eth.getTransactionCount(
      EthereumUtil.bufferToHex(
        EthereumUtil.privateToAddress(privateKeyBuffer)
      ));
    txParams.gasLimit = web3.toHex(gas);
    txParams.nonce = web3.toHex(nonce);
    txParams.gasPrice = web3.toHex(web3.eth.gasPrice);
  }

  var tx = new EthereumTx(txParams);

  tx.sign(privateKeyBuffer);
  return tx;
}
function buildTransaction ( privateKeyHex , toAddress , hash , web3 ) { var privateKeyBuffer = Buffer . from ( privateKeyHex , 'hex' ) ; if ( ! EthereumUtil . isValidPrivate ( privateKeyBuffer ) ) { throw new Error ( 'Invalid private key.' ) ; } var txParams = { nonce : '0x00' , gasPrice : '0x09184e72a000' , // How should we set this? gasLimit : '0x5A88' , to : EthereumUtil . addHexPrefix ( toAddress ) , value : '0x00' , data : EthereumUtil . addHexPrefix ( hash ) } ; if ( web3 !== undefined ) { var gas = web3 . eth . estimateGas ( txParams ) ; var nonce = web3 . eth . getTransactionCount ( EthereumUtil . bufferToHex ( EthereumUtil . privateToAddress ( privateKeyBuffer ) ) ) ; txParams . gasLimit = web3 . toHex ( gas ) ; txParams . nonce = web3 . toHex ( nonce ) ; txParams . gasPrice = web3 . toHex ( web3 . eth . gasPrice ) ; } var tx = new EthereumTx ( txParams ) ; tx . sign ( privateKeyBuffer ) ; return tx ; }
Builds a signed transaction for transmitting,
primarily used internally.
Builds a signed transaction for transmitting primarily used internally .