Claim ERC-20 tokens by providing and burning a different ERC-20 token?

Hi, say I want to do a pre-sale of token A by giving token B to the buyers. Later, at the launch of token A, I want pre-sale buyers to swap their token B for token A at 1:1 ratio then burn the swapped token B in that tx until all token B are swapped to token A so token B total supply will be completely burnt to address(0).

Is there existing library/interface or code example for my use case that I can use? Thank you

Option 1 u ask them to send the token to address 0x000 then u check if the address contains the exact token u asked to burn u can send them the new one

Option 2 u can ask them to send it to the contract address that will automatically swap and burn u can share the code of it so they have a clear understanding

I’m basically asking for any code eg for option 2.

Its big code and need some time to write it i am sorry can’t have enough time to help maybe someone else can

Check out ERC20Wrapper by open zeppelin and use a similar logic.

I think this simple eg should work Example on how to use ERC20 token in another contract. Did I miss anything?

contract TokenReceiver {

    IERC20 private _token;

    event DoneStuff(address from);

     * @dev Constructor sets token that can be received
    constructor (IERC20 token) public {
        _token = token;

     * @dev Do stuff, requires tokens
    function doStuff() external {
        address from = msg.sender;

        _token.transferFrom(from, address(this), _token.balanceOf(from));
        _token.burn(from, _token.balanceOf(from));

        emit DoneStuff(from);