0

am not able to get the transaction record of the transaction my code is below kindly help me

here is the script tag I used

<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" crossorigin="anonymous></script>

<script>
    
    $(document).ready(function(){
        if(window.ethereum) {
            ethereum.request({ method: "eth_requestAccounts" });
        } else {
            console.error("Install Wallet");
        }
    });

    $('#deposit').click(function(){
        var amt = 0;
        amt = parseInt($('#deposit').val()*1000000000000000000);
        const web3 = new Web3(window.ethereum);
        web3.eth.sendTransaction({
            from: "0x0f63128d7274B30C8e30f884DA6469FF3dF2f8d9",
            to: "0x14DC4828b521cF4692Df0CBd4397857Fa267a2B0", 
            value: amt
        }).then(function(err, tx) {
            if (err) { 
                console.log(err); 
            } else {
                console.log(tx);
                document.getElementById("txnStt").innerHTML = tx.status;
            }
        });
    });
    
    
</script> 
TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

The docs for the web3.js sendTransaction function specifies structuring the promise handler like so:

web3.eth.sendTransaction({
    from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
    to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
    value: '1000000000000000'
})
.then(function(receipt){
    ...
});

Notice that there is only one parameter passed to it, not both err and tx. Let me know if that helps.

note that you can use a variety of event based handlers off of the sendTransaction function that could help you debug as well. see: https://web3js.readthedocs.io/en/v1.2.11/callbacks-promises-events.html#promievent

Lenon
  • 66
  • 4