0

Hey I'm calling externals contract method transferFrom in following way.

function sendTransaction(address tokenAddress, uint tokenAmount) public payable {
    if (!performTransfer(tokenAddress, tokenAmount)) {
        revert();
    }

function performTransfer(address tokenAddress, uint amount) internal returns (bool) {
    ERC20Interface instance = ERC20Interface(tokenAddress); 
    bool resp = instance.transferFrom(msg.sender, address(this), amount); 
    return resp;
}

Can someone please tell me if there are any security vulnerabilities in those two functions?

1

The only thing I see is your method sendTransaction don't need to have modifier payable, because it's not dealing with ethers, but with ERC20 token. And you might wanna return true when sendTransaction succeed.

function sendTransaction(address tokenAddress, uint tokenAmount) public returns (bool) {
    require(performTransfer(tokenAddress, tokenAmount));
    return true;
}

function performTransfer(address tokenAddress, uint amount) internal returns (bool) {
    ERC20Interface instance = ERC20Interface(tokenAddress); 
    return instance.transferFrom(msg.sender, address(this), amount);
}
| improve this answer | |
  • Ah thanks for your tips! Really appreciate! :) – Maarduk Feb 23 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.