0

You need to know : i have never touched solididty / eth !

I work for a company that has a token on the BSC. We would like to bridge this token to Solana by burning the token on the BSC and airdroping it on Solana.

First question : can we burn tokens that is not held in our wallet ? (i guess not?)

If not, I need to create the following script :

  1. create a transaction and broadcast it to burn X tokens
  2. check that the transaction was successfull and that X token have effectively been burnt (i guess there is a way to fetch a transaction detail from the blockchain with its signature ?)

I would like to do it with javascript to implement it in our dapp.

Does anyone here can give me advice on where to start, or good tutos to follow ? FYI, i've checked the smart contract source code, and there is a burn function, but no idea how to call it.

EDIT: of course if there is a tool that does that, we can use it as well. Just need to be able to cerate a bridge between the 2 tokens (BSC/SOLANA)

Thank you in advance !

1 Answer 1

0
  • For your first question, can we burn tokens that is not held in our wallet: The answer is No and I think you know why :D.

  • For your second question about burning the token X. There are two frequently method that lots of project uses.

  1. Transfer the token directly to the "burn address", i.e., 0x0000...0, 0x00...1, using Metamask or any wallets. In fact, each blockchain network have their own set of burn address. In your case, BSC chain, you can see their burn address here: https://bscscan.com/accounts/label/burn. Do not worry, no one can touch your token even the bsc member, because it is burned address. Then, announce the transfer to burn address transaction to the community.

  2. Call the burn function from the token contract and annount to community that transaction. You can call that function directly from bscscan or do it with Typescript by the following code

import tokenAbi from token.json;

 burnToken = async () => {
    const rpc = "https://bsc-dataseed1.binance.org/" // assume your token is in BSC, or, replace with other chain;
    const web3 = new Web3(rpc);
    const token_address: string = "0x....";
    const sc = new web3.eth.Contract(tokenAbi as any, token_address); // You can get the tokenAbi from the bscscan, contract code tab
     
    const burnAmount = 1000 * 10**18 // replace with your value and decimal

    // Replace 'YOUR_PRIVATE_KEY' with the actual private key
    const privateKey = 'YOUR_PRIVATE_KEY';

    // Create a new transaction object
    const transactionObject = {
        from: 'YOUR_SENDER_ADDRESS', // Replace with the actual address sending the transaction
        gas: 200000, // Replace with an appropriate gas value
        gasPrice: '1000000000', // Replace with an appropriate gas price
        to: token_address,
        data: contract.methods.burn(inputParameter).encodeABI(),
        nonce: web3.utils.toHex(await web3.eth.getTransactionCount('YOUR_SENDER_ADDRESS'))
    };

    // Sign the transaction
    const signedTransaction = await web3.eth.accounts.signTransaction(transactionObject, privateKey);

    // Send the signed transaction
    web3.eth.sendSignedTransaction(signedTransaction.rawTransaction)
    .on('transactionHash', function (hash) {
        console.log('Transaction Hash:', hash);
    })
    .on('receipt', function (receipt) {
        console.log('Receipt:', receipt);
    })
    .on('error', function (error) {
        console.error('Error:', error);
    });

 }

More details you can see in this link: https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html?highlight=sendSignedTransaction#sendsignedtransaction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.