Moa*_*med 5 error-handling modifier reactjs ethereum smartcontracts
我正在使用 React 开发一个 web3 项目,并在 Rinkeby 测试网上部署一个合约。我故意发送无法成功执行和确认的请求,但捕获恢复消息并在浏览器中显示信息。在 Remix 上测试合约时,我注意到如果某个方法未通过修饰符,您确实会看到合约代码下方的窗口中显示的错误消息。
当我从非白名单地址调用合约时,在控制台中我收到以下消息:
call to Contract.doStuff errored: VM error: revert.
revert The transaction has been reverted to the initial state.
Reason provided by the contract: "Your wallet address is not yet whitelisted.". Debug the transaction to get more information.
Run Code Online (Sandbox Code Playgroud)
但在 React UI 中,在控制台中我收到以下消息:
{
"blockHash": "0x6c36210443eb483cb5bf880da03c51611a771e3452875989084c48d8ea3bbc48",
"blockNumber": 10247168,
"contractAddress": null,
"cumulativeGasUsed": 7066125,
"effectiveGasPrice": "0x9502f911",
"from": "0x4e824b1b274beb70f4205afc2c6bcb8797f770ca",
"gasUsed": 30249,
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": false,
"to": "0x0cae9c086399b6fdcda84ad9b1072933a87f38f9",
"transactionHash": "0x1e8d71b3811f6c310819ec80e95c43140fd10c79cb3d017299c161dbde670198",
"transactionIndex": 9,
"type": "0x2",
"events": {}
}
at Object.TransactionError (errors.js:90:1)
at Object.TransactionRevertedWithoutReasonError (errors.js:101:1)
at index.js:437:1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
901 次 |
| 最近记录: |