1

I have a piece of code like so:

address x=0x01234..;
x.call(data1, data2, data3); 

Will this do what I expect and call the contract at address x while passing the data in concatenated like data1+data2+data3 (and bare, without any solidity ABI formatting)? I can't find any documentation about this.

5

The low-level .call function allows you to call a function by its function signature calculated as bytes4(sha3("functionName()")). Also take a look at https://ethereum.stackexchange.com/a/9722/16 and Call contract and send value from Solidity. If your function has parameters, the signature looks as follows bytes4(sha3("functionName(uint256,string,address)")) - keep in mind that instead of uint you have to use uint256. The following parameters are the actual values of the parameters. Thus, the whole call would look like

x.call(bytes4(sha3("functionName(uint256,string,address)")), myUIntVal, myStringVal, myAddressVal);

You can also specify a specific gas or value (ether (but in Wei!) to send along) like this:

x.call.value(1234)(bytes4(sha3("functionName(uint256,string,address)")), myUIntVal, myStringVal, myAddressVal);
  • Cool, that matches what I was thinking it did, but couldn't find any documentation confirming it or even indicating that call can take multiple arguments – Earlz May 3 '17 at 21:08
  • IMO most documentation is still patchy. Please do help other people here or on sites where you find some info missing and would expect it. – Validity Labs - Sebastian May 4 '17 at 8:50

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.