Search code examples
javascriptethereumweb3jsmetamask

How to listen to Metamask's web3's "confirm"/"cancel" event of a contract?


Since metamask's injected web3 follows https://github.com/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()

metamask's pop for user to confirm/cancel

Is there a way to catch the event?


Solution

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