Ethereum 如何使用多个参数调用合约函数?

Ethereum 如何使用多个参数调用合约函数?,ethereum,solidity,web3,Ethereum,Solidity,Web3,我试图调用一个包含3个参数的Solidity契约函数。 下面是我的契约函数的样子 function test(string memory a, string memory b, string memory c) public{ // Does something here (alters the data in the contract) } 我现在尝试使用web3版本1.2.1向该函数发送事务,但遇到错误 instance = await new web3.eth.Contract(JSO

我试图调用一个包含3个参数的Solidity契约函数。 下面是我的契约函数的样子

function test(string memory a, string memory b, string memory c) public{
 // Does something here (alters the data in the contract)
}
我现在尝试使用web3版本1.2.1向该函数发送事务,但遇到错误

instance = await new web3.eth.Contract(JSON.parse(abi), address);
instance.methods.test("hello_a","hello_b","hello_c").sendTransaction({from:account});
代码位于async()块中,传递的所有参数都是正确的。然而,我得到一个错误,说sendTransaction不是test的函数


我遗漏了什么?

您应该使用
send
而不是
sendTransaction

instance.methods.test("hello_a","hello_b","hello_c").send({from:account});
您可以阅读有关可用方法的更多信息