1

When one submits a transaction with data ex: eth.sendTransaction({from:eth.accounts[0],to:contractAddress,value:web3.toWei(1,"ether"),data: ...)

What is the purpose of including input data? especially when it is sending it to contract address?

1

If we relate to web3 docs here https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethsendtransaction , which i assumed you are using.

The data value you are asking about is a byte code of a message sent to the receiving account, or an initialization code (a byte string) of the contract in case were the transaction is creating one.

| improve this answer | |
  • 3
    Just another common example: the data parameter is also needed for calling a non-constant function of a smart contract. In this case the parameter holds the hex code of the function call including the arguments. – joffi Feb 15 '18 at 16:27

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.