From js, I typically call a function with something like this:

theFunction.someMethod(param1, param2, param3, 
    {"from": 0x111222..., "to": 0x1234..., "value":web3.toWei(2, 'ether')});

I would like to also display for the users how they would achieve the same manually, using the geth console, something like

web3.eth.sendTransaction({'from':0x111222..., 'to':0x1234,
    'value':web3.toWei(2, 'ether'), 'data': 0xXXXXXXX})

So, how do I get the 0xXXXXXXXX part from my original theFunction.someMethod(...) call? I know it can be calculated, but web3 can obviously do so already, so I don't want to reinvent the wheel.

1 Answer 1


Use getData.


// Get the call data, so you can call the contract through some other means
var myCallData = myContractInstance.myMethod.getData(param1 [, param2, ...]);
// myCallData = '0x45ff3ff6000000000004545345345345..'

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.