最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to listen to Metamask's web3's "confirm""cancel" event of a

programmeradmin1浏览0评论

Since metamask's injected web3 follows

But there seems to be no coding to catch the confirm/cancel button clicking event (img below) when calling contract.new()

Is there a way to catch the event?

Since metamask's injected web3 follows https://github./ethereum/wiki/wiki/JavaScript-API

But there seems to be no coding to catch the confirm/cancel button clicking event (img below) when calling contract.new()

Is there a way to catch the event?

Share Improve this question edited Mar 23, 2023 at 20:55 TylerH 21.1k79 gold badges79 silver badges114 bronze badges asked Sep 26, 2018 at 6:52 UnrealityUnreality 4,21211 gold badges50 silver badges68 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

To handle Confirm/Cancel response of user on your contract functions, you can use the transactionHash event & error event from send function.

"transactionHash" returns transactionHash: String: Fired when the transaction hash is available.

"error" returns error: Error: Fired if an error occurs during sending. If the transaction was rejected by the network with a receipt, the receipt will be available as a property on the error object.

You can see detail here.

When you click on Confirm button then you can handle this case in the transactionHash event.

When you click on Cancel button then you can handle this case in the error event.

If the user clicked the 'cancel' button, the 'processedContract' variable below will be undefined.

If confirmed, it will be the contract and if it has an address ( processedContract.address ) then it is being mined.

newContract.new({...}, function(e, processedContract) {...});

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论