Approval Transactions

Prompt For an Approval #

It’s a common practise to have your DAPP transfer TAU on the user’s behalf espeically if you are going to have them pay for certain things on the blockchain.

Usually this would require the user to create and send a currency.approve transaction first.

You can initiate this process on the user’s behalf, and the Lamden Wallet will prompt them to accept the Approval Request.

Approval popups ALWAYS show, regaless of your DAPP’s Trusted Status.

Create an Approval Transaction #

const detail = JSON.stringify({
    contractName: 'currency',
    methodName: 'approve',
    networkType: 'mainnet',
    kwargs: {
        amount: 100,  // amount of TAU to approve
        to: 'con_your_contract_name' // contract to approve
    }

    stampLimit: 100; 
});

Send Transaction #

//Send transaction to the wallet
document.dispatchEvent(new CustomEvent('lamdenWalletSendTx', {detail}));

Listen for Transaction Result #

document.addEventListener('lamdenWalletTxStatus', (response) => {
    if (response.resultInfo.type === 'error') {
        console.log(response.resultInfo.errors)
        //Handle Errors
    }else{
        //Do soemething
    } 
});
Updated on February 3, 2021