我有问题。
我牢固地拥有这份合同:
pragma solidity >=0.4.21 <0.6.0;
contract SimpleStorage {
string public storedData;
uint public i;
constructor(string memory initVal) public {
storedData = initVal;
i = 0;
}
function setDati(string memory x) public returns (uint) {
storedData = x;
i++;
return i;
}
function getAll() public view returns (string memory) {
return storedData;
}
}
getAll函数使用以下代码工作:
import SimpleStorageContract from "./build/contracts/SimpleStorage.json";
import getWeb3 from "./utils/getWeb3";
/*inizialize web3 using
const provider = new Web3.providers.HttpProvider(
"http://localhost:22003" //quorum node 4
*/
const contract = new web3.eth.Contract(
SimpleStorageContract.abi,
deployedNetwork && deployedNetwork.address,
);
const response = await contract.methods.getAll().call();
但是当我使用setDati函数不能使用此错误时:
// ERROR: {error: Error: Number can only safely store up to 53 bits}
await contract.methods.setDati("ANSIA").send({from: accounts[0]});
/* where accounts[0] is:
const accounts = await web3.eth.getAccounts();
*/
我们尝试进行各种测试: 1.没有错误,没有结果:
//without .send() like this:
await contract.methods.setDati("ANSIA");
await contract.methods.setDati("ANSIA", {privateFor:["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="]});
问题是: 如何在Angular dapp中使用setDati函数?