Can someone point me in the direction of how to create a smart contract that buys BEP20 tokens? For example, a user inputs 1 BNB and gets three different tokens on BEP20 for this automatically in his wallet.
Thanks in advance
Can someone point me in the direction of how to create a smart contract that buys BEP20 tokens? For example, a user inputs 1 BNB and gets three different tokens on BEP20 for this automatically in his wallet.
Thanks in advance
The smart contract has to have those tokens that are available for sale, you make a function to buy tokens, and in that function you transfer those BEP20 tokens to the address that sent that 1 BNB to the smart contract.
Sometimes you can find the contract source on etherscan for various smart contracts, for example this https://etherscan.io/address/0x0990faeff7fa89dd42a4c645b2aba0b209f06fa6#code (it doesnβt do what you want, but maybe you can find another smart contract that it is closer to what you are looking for).
Thanks! But I do not even know how to create a function to buy tokens (and buy from where?). I found this: https://docs.uniswap.org/protocol/V2/reference/smart-contracts/router-02#swapexactethfortokens
Here I can swap tokens for ETH on Uniswap. Thatβs basically what I want, but swapping BEP20 tokens is not possible with this.
Thanks, that brings me a step further!