4

Working with a contract that has multiple parameters just wondering what the correct syntax would be for.

// creation of contract object
var MyContract = web3.eth.contract(abi);

// initiate contract for an address
var myContractInstance = MyContract.at('0x78e97bcc5b5dd9ed228fed7a4887c0d7287344a9');

var result = myContractInstance.myConstantMethod('myParam');
console.log(result) // '0x25434534534'

myContractInstance.myStateChangingMethod('someParam1', 23, {value: 200, gas: 2000}, function(err, result){ ... });

//This is where I'm not sure???????
myContractInstance.myStateChangingMethodMultiParm('someParam1', 23, 'someParam2', 23, {value: 200, gas: 2000}, function(err, result){ ... });
// Or
myContractInstance.myStateChangingMethodMultiParm({'someParam1':23, 'someParam2': 23}, {value: 200, gas: 2000}, function(err, result){ ... });
5

If your Solidity function is like so:

function myStateChangingMethodMultiParm(uint param1, uint param2) ()

Then you call it like so:

myContractInstance.myStateChangingMethodMultiParm(
    23,
    24,
    { from: myAccount, value: 200, gas: 2000 },
    function (err, result) {});

Normally you can omit the gas: parameter.

3

This one works fine:

myContractInstance.myStateChangingMethodMultiParm('someParam1', 23, 'someParam2', 23, {value: 200, gas: 2000}, function(err, result){ ... });

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.