Vishakha Lall
Vishakha Lall

Reputation: 1324

How to call a contract function with multiple arguments?

I am trying to call a function of my Solidity contract that takes in 3 arguments. Here's what my contract function looks like.

function test(string memory a, string memory b, string memory c) public{
 // Does something here (alters the data in the contract)
}

I am now trying to use web3 version 1.2.1 to send a transaction to this function but I'm encountering errors.

instance = await new web3.eth.Contract(JSON.parse(abi), address);
instance.methods.test("hello_a","hello_b","hello_c").sendTransaction({from:account});

The code is in an async() block and all the arguments passed are correct. However I get an error saying sendTransaction is not a function of test.

What am I missing out here?

Upvotes: 2

Views: 6939

Answers (1)

Vitaly Migunov
Vitaly Migunov

Reputation: 4467

You should use send instead of sendTransaction

instance.methods.test("hello_a","hello_b","hello_c").send({from:account});

You can read more about available methods there

Upvotes: 4

Related Questions