I can't check if the transaction took place using then() and txHash

Hello to all,

I’m currently developing a site using Metamask. For the proper functioning I need to know if the transaction has been accepted or not by the user. For this I had the idea to retrieve the error code (4001 if the user refused the request) returned by the sendTransaction method in ethereum.request() using this code:

        await ethereum.request({
            method : 'eth_sendTransaction',
            params : [{
                from: accounts[0],
                value: newValue,
        }).then(txHash => console.log(txHash));

Everything works correctly: the transaction request is done and the user refuses, a message appears in the console (as a promise object). However, it is impossible to retrieve this object and therefore the error code that is in it to check if the transaction has been made or not. I would like to know if anyone has a solution or even another method to check the status (accept or decline) of a transaction request.

Thanks in advance for your help.

This topic was automatically closed after 30 days. New replies are no longer allowed.