A Burn Function Help!

Hello everyOne,
I need help to finish this function
I have a token, and I need to implement the burning function in my dapp.
Here is the source code, (BSC-Tesnet)

async function burn(){

let addressToken = “_____”;

const amount = document.getElementById(“amountBurn”).value;

const tx = {

from: accounts[0],

gas: Number(21000).toString(16),

gasPrice: Number(11000000000).toString(16),

data: contrato.methods.burn(web3.utils.toWei(amount.toString())).encodeABI(),

     }

web3.eth.sendTransaction(tx).then(res => {

  console.log("res",res)

}).catch(err => {

  console.log("err",err)

});

let result = await window.ethereum.request({method: “eth_sendTransaction”, tx}).catch((err)=>{console.log(err)});

}

What is the actual issue?

in this way the pop up appears, but the cost is too high, and warns that it will not work

async function burn(){

let addressToken = “_______________________________”;
const amount = document.getElementById(“cantidadQuema”).value; //textbox html

const tx = {
from: accounts[0],
data: contrato.methods.burn(web3.utils.toWei(amount.toString())).encodeABI(),
}
web3.eth.sendTransaction(tx).then(res => {
console.log(“res”,res)
}).catch(err => {
console.log(“err”,err)
});

let result = await window.ethereum.request({method: “eth_sendTransaction”, tx}).catch((err)=>{console.log(err)});

}

Is contrato.methods a typo

The contract definitely has a ‘burn’ function??

Seems very high cost but also you would expect to see the method in MM as ‘BURN’ and you only see ‘Contract interaction’

Contrato means contract in Italian…

2 Likes

“cantidadQuema” means amout to burn, its a HTML tag.
definitely has a ‘burn’ function? yes, and is public, its a burneable token. ERC20 Standar