【发布时间】:2021-08-20 03:01:46
【问题描述】:
我已经创建了带有函数的智能合约:
function putOrder() external payable {
require(msg.value == itemPrice);
(bool sent, bytes memory data) = shopManager.call{value: msg.value}("");
require(sent, "Failed to purchase");
}
这只是检查 eth/bnb 值是否正确传递给函数,然后将其发送到管理器地址。
这就是我在 web3 上的 react 函数的样子:
const putOrder() = async () => {
...
window.contract.methods.orderStuff().send({from: accounts[0]}).on(
'receipt', function(){
processOrder();
}
);
...
}
很明显,我收到了一个错误,即 itemPrice 不满足。那么如何通过 eth/bnb 值通过 web3 发送到合约函数调用呢?
【问题讨论】:
标签: blockchain ethereum solidity smartcontracts web3