1

Every now and then I'll see someone say just copy/send the raw tx hex, I guess to copy the transaction - like an nft mint - and send it faster instead of writing through the contract?

Is this correct? If so, how do you send that raw tx hex? If not, then what's the purpose of the raw tx hex?

1 Answer 1

1

It depends on your needs.

Usually, while using web3.js, ethers.js, Metamask, etc., we create a transaction, sign it and send it automatically. Sometimes you may want to simply create a transaction and sign it without sending it. Maybe you want to wait for something before sending the raw transaction, sharing it, or whatever.

Most of the time you just need to send your transaction and using a tool like web3.js and passing a JSON with the details of your transaction will be enough.

The EVM does not understand JSON. It only understands hex. So, at the end, your transaction will be converted to hex and sent to the blockchain.

You can sign your transaction using web3.eth.accounts.signTransaction

https://web3js.readthedocs.io/en/v1.7.5/web3-eth-accounts.html#eth-accounts-signtransaction

That will return a response with hex string in the field rawTransaction, which is the raw transaction hex. You can save it or do whatever you need with it.

You can send/broadcast the raw signed transaction using web3 sendSignedTransaction function.

https://web3js.readthedocs.io/en/v1.7.5/web3-eth.html#sendsignedtransaction

You can send a JSON transaction using: web3.eth.sendTransaction function.

https://web3js.readthedocs.io/en/v1.7.5/web3-eth.html#sendtransaction

You can copy a raw hex transaction and put it through web3.eth.accounts.signTransaction to sign it, and then use web3 sendSignedTransaction to send/broadcast it.

In Metamask you could go to Settings -> Advance -> Show Hex Data and activate the hex data input to put custom hex data (to call a contract or something like that). I would look like this:

enter image description here

4
  • makes sense. So when I see people say just copy the raw tx hex, in regard to an nft mint, are they not copying it and then submitting it somewhere on metamask to copy an early transaction? Sep 13 at 20:08
  • Maybe they are referring to copying the raw transaction (the transaction that is not yet signed), signing it yourself, and broadcasting it. I think that would be faster than manually creating the transaction yourself, signing it, and then broadcasting it. I think that's a good strategy to copy and replay a transaction quickly. Sep 13 at 20:19
  • how would that work tho? where do you put that into like metamask/frame/etc? or do you do that thru etherscan? Sep 14 at 0:09
  • Check the update in the answer. Sep 14 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.