0
  const Web3 = require('web3')
  const web3 = new Web3(`https://mainnet.infura.io`)

  const privateKey = 'privateKey'
  const tx = {
    from: '0x1',
    to: '0x2',
    value: web3.utils.toWei('3', 'ether'),
    gasPrice: web3.utils.toWei('3', 'gwei'),
    gas: 21000,
    nonce: 0,
    chainId: 1
  }

  const signed = await web3.eth.accounts.signTransaction(tx, privateKey)
  console.log(signed.rawTransaction) // <- HERE

I get transacton raw with 220 symbols, sometimes length is 218 symbols. Could you please share regex for validating ethereum signed transaction raw.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Yegor
  • 3,652
  • 4
  • 22
  • 44
  • 1
    What specifically are you trying to validate? The result will always be a hexadecimal encoding of some bytes. If you want to validate that you have hexadecimal, that's easy (optional leading `0x` followed by an even number of digits in `[0-9a-fA-F]`). If you want to check for a valid Ethereum transaction, you'll have to decode the data, process the RLP encoding, and validate the values. – user94559 Jun 16 '19 at 17:16
  • I wanted validate length, but decoder is the best solution for my case, thanks) – Yegor Jun 16 '19 at 17:24

0 Answers0