admin管理员组

文章数量:1023102

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) {...});

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) {...});

本文标签: