由于图中出现错误,我无法调用该方法。我不知道如何解决,您有什么建议吗?
在NodeJS中调用智能合约方法的函数是:
async function callSmartContractMethod(functionName, arguments, contractAddress) {
smartContractInstance = new web3.eth.Contract(JSON.parse(contractJson).abi, contractAddress, {
from: "0x8882528C7104e146E0500203C353C09922575385",
gasPrice: '1000000'
});
log.yellow(`Calling smart contract function: ${functionName} with arguments: ${arguments} smart contract address is: ${contractAddress}`);
log.yellow.underline('Please wait...');
return smartContractInstance.methods[functionName].apply(this, arguments).send({from: '0x8882528C7104e146E0500203C353C09922575385'})
.then((receipt) => {
log.green(`Transaction of ${functionName} done with success`);
return receipt;
}).catch( (error) => {
log.red.underline(error);
});
}
调用智能合约的方法(Solidity)为:
function printOrderReceived(bytes32 _gcodeHash) public {
require(msg.sender == printer);
gcodeHashReceived = _gcodeHash;
b_printOrderReceived = true;
getCurrentState();
}
package.json文件的部分依赖项是:
"truffle-hdwallet-provider": "0.0.3",
"truffle-hdwallet-provider-privkey": "^1.0.3",
"web3": "^1.0.0-beta.48"