0

I'm new to Solidity. My contract tries to receive the Chainlink ERC20 token on Rinkeby testnet from a users address.

First transaction: user gives approval. This goes through.

Second transaction: user calls contract function to pull the token. This fails by error "execution reverted".

// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;

interface IERC20 { function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); }

contract theContract {

//Chainlink Contract Address on Rinkeby
IERC20 myToken = IERC20(0x01BE23585060835E02B77ef475b0Cc51aA1e0709);

function askForApproval(uint256 amount) public payable returns (bool) {
    return myToken.approve(address(this), amount);
}

function pullToken(uint256 amount) public payable returns (bool) {
    return myToken.transferFrom(msg.sender, address(this), amount);
}

}

I kind of gave up on this. Would be very glad if someone can give me a hint. Thanks

0 Answers0