I have a contract with an ABI and I'm currently interacting with it on ropsten network.

I have this function that ask metamask to sign transaction, it's a smart contract interaction and I transfer a NFT token to another address :

async function transferToken(index) {
    let address = document.getElementById("inputTransferAddress").value;
    const account = await getCurrentAccount();
    const tx = await MyContract.methods.transfertoken(address, index).send({ from: account })

Metamask ask me to sign the transaction, and data for this smart contract interaction :

GAS FEE 0.000281

FUNCTION TYPE:Contract Interaction

Is there away to read up this "hex data" without sending them to metamask ?

I want to do it on a FUTURE transaction, because I want to make a scannable QRCODE with a raw transaction.

1 Answer 1


The hex data in the question is data field that goes to the Ethereun smart contract.:

transfertoken(address, index)

  • 4 bytes for hash transfertoken(address,index) string - choosing which smart contract function is called
  • 256 bits (32 bytes) for address
  • 256 biys (32 bytes) for index

You can use ABI encoding and decoding facilities of Web3.js to create the transaction payload yourself, exactly what methods.xxxx.send does internally.

However your idea of FUTURE transactions is likely based on false assumptions, because of not understanding how blockchain transactions work. It is easier to make a QR code to go to a web page where user can do a transaction using WalletConnect link. There is no wallet that supports signing a raw transaction from QR code and your question sounds like XY problem.

  • 1
    Thanks for the solution and WalletConnect Link !
    – GrindCode
    Apr 18, 2021 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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