[英]Sending value to a solidity contract method from web3 results in `Invalid Tuple Value` error
我正在使用web3
將值發送到web3
solidity 0.5.1
方法,並不斷收到invalid Tuple value
錯誤。
以下是相關的合同代碼:
struct mystruct {
bytes32 id;
string str;
}
mapping (bytes32 => mystruct) structs;
function creatMyStruct(bytes32 id, string memory str) public {
mystruct memory newStruct = mystruct(id, str);
structs[id] = newStruct;
}
我從node.js
調用它:
contract.methods.creatMyStruct(someId, someString).send({from: fromAccount, gas: gasEstimate})
.then(receipt => {
var txhash = receipt.transactionHash;
resolve(txhash);
},
(error) => {
reject(error);
}).catch((err) => {
reject(err);
});
我嘗試發送一個string
,一個number
並將該字符串轉換為hex
。 相同的錯誤: invalid tuple value
。 我想念什么?
編輯:您正在實例化新的結構錯誤。 問題是合同。 看到正確的方法
function creatMyStruct(bytes32 _id, string memory _str) public
{
mystruct storage newStruct = mystruct({id: _id, str: _str});
structs[id] = newStruct;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.