0

I'm using web3 to deal with transactions, I have a custom token and I would like to be able to send it in the transactions.

const amount = web3.utils.toWei(amountPurchase, 'ether');
const value = web3.utils.toHex(amount);
const transactionParameters = {
    nonce: '0x00',
    to: 'my_wallet',
    from: ethereum.selectedAddress,
    value: value,
    data:
    '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
    chainId: '0x3',
};

try{ const txHash = await ethereum.request({ method: 'eth_sendTransaction', params: [transactionParameters], });

This is my token contract address: 0x2e877C25bfaFbFE1F7643FCfcb14078e228D085F this is in the BSC but I think that it is the same. How can I send this token instead of BNB? The token is only in the test net for the moment. Thank you all in advance.

  • https://ethereum.stackexchange.com/questions/23121/how-to-transfer-erc20-tokens-using-web3js. https://ethereum.stackexchange.com/questions/95218/how-can-i-transfer-tokens-of-my-erc20-automatically-from-the-server. and more – Majd TL Dec 06 '21 at 13:50
  • @MajdTL I have already read all of them but still not working for me, for this reason I asked for help :) – Quique Fernandez Dec 06 '21 at 15:14
  • Hi QuiqueFernandez! In the linked question scroll down you need to use the version for web3 1.0 by OnlyoneFinance. – Ismael Dec 08 '21 at 04:09

0 Answers0