0

I am doing some work with the pancakeswap predictions smart contract (https://bscscan.com/address/0x0E3A8078EDD2021dadcdE733C6b4a86E51EE8f07#code) and am trying to make a transaction using the betBull transaction. My code looks like the following:

wallet.js

const bullWalletTwo = web3.eth.accounts.wallet.add(
  web3.eth.accounts.privateKeyToAccount(process.env.BULL_PRIVATE_KEY_TWO)
);

const bullWalletSignerTwo = new Wallet(
  process.env.BULL_PRIVATE_KEY_TWO,
  new JsonRpcProvider(process.env.BSC_RPC)
);

let bullContractTwo = new Contract(
  process.env.PCS_ADDRESS_CAKE.toString(),
  pspAbi,
  bullWalletSignerTwo
);

const bullPredictionContractTwo = bullContractTwo.connect(bullWalletSignerTwo);

module.exports = {
  bullPredictionContractTwo
};

bets.js

/**
 * Bets up using the bull wallet.
 * @param {*} amount the amount to bet
 * @param {*} epoch the epoch to bet on
 */
const betBullTwo = async (amount, epoch) => {
  try {
    console.log(`Round ${epoch} - Betting 🐂...`);
    const tx = await bullPredictionContractTwo.betBull(epoch, {
      value: parseEther(amount.toFixed(18).toString()), // <-- I think the problem is somewhere here
    });
    await tx.wait();
    console.log(
      `Round ${epoch} -🤞🐂 Successful bet of ${amount} CAKE to UP 🍀`
    );
    return true;
  } catch (e) {
    console.log(`Round ${epoch} - ❌🐂 Bull - Transaction Error ${e}`);
    return false;
  }
};

test.js

const test = async () => {
  betBullTwo(0.5061855670103093, 40314); // first number is the number of cake I want to buy, second number is the epoch to buy for (see the smart contract linked above)
};

test();

THE ERROR

Bull - Transaction Error Error: insufficient funds for intrinsic transaction cost [ See: https://links.ethers.org/v5-errors-INSUFFICIENT_FUNDS ] 
(error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"id\":52,\"error\":{\"code\":-32000,\"message\":\"insufficient funds 
for transfer\"}}","error":{"code":-32000},"requestBody":"{\"method\":\"eth_estimateGas\",\"params\":
[{\"gasPrice\":\"0x61a8\",\"value\":\"0x706551760144488\",\"from\":\"{address kept secret}\",\"to\":\"{address kept secret}\",\"data\":\"0x57f
b096f0000000000000000000000000000000000000000000000000000000000009d7a\"}],\"id\":52,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"https://bsc-dataseed.binance.org/"}, 
method="estimateGas", transaction={"from":"{address kept secret}","gasPrice":
{"type":"BigNumber","hex":"0x61a8"},"to":"{address kept secret}","value":
{"type":"BigNumber","hex":"0x0706551760144488"},"data":"0x57fb096f0000000000000000000000000000000000000000000000000000000000009d7a","accessList":null}, code=INSUFFICIENT_FUNDS, 
version=providers/5.7.2)

Help?

I do have sufficient CAKE and BNB for the transfter. I have 2 CAKE and 0.04 BNB. More than enough for the transaction. Does anyone know what's wrong? I can't figure it out. As I noted alin the code, I think the problem is in the parseEther function in bets.js but I'm not quite sure...

1
  • Did you find a solution for this? Dec 18, 2022 at 21:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.