Hello guys.
I am currently using an html page that is available to my users. I need to set up a button that allows the spending of BUSD or other stablecoin tokens on the same page.
Once the button is clicked I want Metamask to open and ask the user if they want to approve the address (for example: 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56) for the BUSD token spending.
I found an approach that works well for connecting and loading the wallet. BUT the transaction for the approve function does not work. Here is my code:
async function connectMetamask() {
const web3 = new Web3('https://bsc-dataseed1.binance.org:443');
await window.web3.currentProvider.enable();
const proxy = "BuyerAdress"; // spender adress
const TOLaddress = "MyTokenAddress";//my coin adress
const value = "100"; // value
approve(proxy, 0); //i need approve one time for client adress
}
Thank you very much for your help, I’m stuck for some time on this problem.
Thank you very much for your help, I’m stuck for some time on this problem.