For educational purposes, I would like to manually create and publish a transaction. I want to see what's needed for the transaction and how everything is done.
With my current code, using Etherscan's transaction broadcaster works, it gets accepted at first, but the transaction always gets thrown out of the pending transactions.
I'm using ethereumjs/tx and web3 in the following way, mostly copied from ethereumjs/tx with a fresh account with some Ether on it (which is why the nonce is 0):
const address = '0x078bB609037E36D43800E1C7531Dbd4f8f1fDd12'
const txParams = {
nonce: web3.utils.toHex(0),
gasPrice: web3.utils.toHex(2),
gasLimit: web3.utils.toHex(500000),
to: '0x0000000000000000000000000000000000000000',
value: '0x00',
data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
}
const common = new Common({ chain: 'rinkeby' })
const tx = Transaction.fromTxData(txParams, { common })
const signedTx = tx.sign(privateKey)
const serializedTx = signedTx.serialize()
console.log(serializedTx.toString("hex"))
After which I manually publish the serialized transaction using Etherscan.
Can someone point out where I'm going wrong?