When sending ETH to another address via metamask, I confirmed that I can also send input data. For example, 0x7465737420746573742074657374

But I also want to know if it's possible to manipulate input data created by web3 like below:

App.contracts.Soccer.deployed().then(function(instance) {       
    return instance.purchaseShoes(name, age, { from: accounts[0], value: value});
}).then(function() {

When creating a transaction using above code, web3 will pack function name, input parameters and so on in the data field of transaction and creates input data in etherscan which are the values I passed to purchaseShoes's parameters.

I know it sounds a bit weird, but like I was able to send input data from metamask, would I be able to modify input data to any content I want before web3 creates the values and send it to etherscan?

1 Answer 1


Yes, you can modify the input data field before the transaction is sent. But that transaction will not be understood by your contract and will end up in the fallback. Note that this is possible only before signing the transaction which means that there are not security issues (like someone changing the input data of a transaction).

You can create a transaction like this:

tx = {to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55',
    value: '1000000000',
    gas: 2000000,
    gasPrice: '234567897654321',
    nonce: 0,
    input: 'somedata'
    chainId: 1}

This is what web3 is doing automatically for every function, the 'some data' is related to the smartcontract definition of the functions. Yet nothing stop you from changing the input field.

Hope this helps

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.