0

In order to allow BUSD payments on my Smart Contract (SC) I am declaring

    IERC20 busd = IERC20(address(0x0Ca2fec84fAB02eE11882Bcca1982c6e72Ae8Ad1));

in order to let transact like (1)

   busd.transfer(account, reward);

I am deploying the Busd clone like:

// contracts/BEP20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract Busd is ERC20 {
    constructor() ERC20("Busd", "BUSD") {
        _mint(msg.sender, 1000000 ether);
        _mint(0x5595889316eDF0C50AcdB689ff785f88EB5b60f4, 1000000 ether);
        _mint(0x380772d13c6501622bb1eFBc01f3EAa98557BE24, 1000000 ether);
        _mint(0xEfD55A463626D5b012839D220Cd57B8bb9286e51, 1000000 ether);
    }
}

But although I can check my balance is about 1000000 Fake Busd's on different accounts when I run the transaction (1) I always get the same error: Transfer amount exceeds balance

reason: 'ERC20: transfer amount exceeds balance',
  hijackedStack: 'StatusError: Transaction: 0x5f7dafcccb64e0d0dfe922d0821aba7da69b1fbe27d8d73069844e728cb324e5 exited with an error (status 0). Reason given: ERC20: transfer amount exceeds balance.\n' +

I am working on localhost with ganache with the Fake BUSD token deployed in order to test... I will be grateful with suggestions to make this work ;)

edit: +++

right @Skyge FInally it continues not working :/ this is the function where I expect to receive BUSD to transfer them from user to project wallet (or to deployed smart contract)

function buyNft(uint256 _value) public returns (bool) {
        address sender = address(msg.sender);
        uint256 busdUserBalance = BUSD.balanceOf(sender);
        require(busdUserBalance >= _value,"not enough balance first require buyNFT");
        // check BUSD availability
        uint256 bonusPaid=0;
        bool exists = false;

        for (uint i = 0 ; i < 7 ; i++)
            if ( allowedValues[i] ==  _value ){
                exists = true;
                break;
            }

        require(exists, "Sorry NFT of that value is not available by now");

        // get payment

        BUSD.approve(address(this),_value);
        BUSD.transferFrom(sender, address(this),_value);
}

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.