-1

e.g; With the receive() function in the BEP20 network, I capture when a money is transferred and trade with a script. But when other tokens such as WBNB, USDT are sent, I cannot do anything.

What I want to do: convert all coins and tokens directly transferred to the contract to busd via receive or fallback (or whichever works with) pancakeswap and mapping(address => uint) balance; I want to import the MAP into it.

I searched a lot but couldn't find the result I was looking for.

Could you please share which is the required source code for this process?

I using this function:

contract SendMoney{

        mapping(address => uint) balance;


        receive() external payable {
                    SendedMoney(msg.sender, msg.value);
                }


       function SendedMoney(address _senderaddress, uint _amount){
        balance[_senderaddress] = _amount;
        }
}
hertac
  • 9
  • 2

1 Answers1

1

Those are BEP20 Tokens they don't have a receive() function.

This means the smart contract doesn't know that somebody sent you those tokens.

You would have to implement some off-chain bot that would track if your contract got any tokens and then call some swap() function.

Kuly14
  • 496
  • 3
  • 12