2

Guys i'm trying to do an manual trade bot in pancake for study , but i can't understand what it's wrong with my code now , i'm trying for a few days understand what is wrong but i really don't know what is happen.

const Web3 = require('web3');

async function swapToken(privateKeys, tokenAddress, amount, bnbAddress) {
  // made an web3 instance with URL from Binance Smart Chain
  const web3 = new Web3(new Web3.providers.HttpProvider('https://bsc-dataseed.binance.org/'));

  // Get atual gás price
  const gasPrice = await web3.eth.getGasPrice();

  // Loop to get all pk's
  for (const privateKey of privateKeys) {
    // get the account of my pk
    const account = web3.eth.accounts.privateKeyToAccount(privateKey);

    // define transaction options
    const options = {
      from: account.address,
      to: tokenAddress,
      value: 0,
      gasPrice: gasPrice,
      gas: '200000',
      data: bnbAddress,
    };

    // assign and send the transaction to trade token
    const signedTransaction = await web3.eth.accounts.signTransaction(options, privateKey);
    web3.eth.sendSignedTransaction(signedTransaction.rawTransaction);
  }
}

// all pk ( multi wallet system)
const privateKeys = [
  'my private key'

];

// token address on Binance Smart Chain
const tokenAddress = '0xe9e7cea3dedca5984780bafc599bd69add087d56';

// Quantity of tokens to be traded
const amount = '2';

//token output
const bnbAddress = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c';

swapToken(privateKeys, tokenAddress, amount, bnbAddress);

and the error is : error after run the code

i tried some changes in code variables but nothing really works ... I'm really need help with this error and understand what is wrong to do this error

0 Answers0