I'm having trouble getting a solidity contract method to transfer ERC20 tokens from address A to B assuming B has called approve outside the contract and setup sufficient allowance for A. The allowance value prints fine inside the contract but the transferFrom fails. I'm missing something in how the ownership and signatures are set up. I do have a workaround where the same transferFrom works outside the contract but I'd like to do it inside.

I set up a sample repo with truffle tests and an issue to describe the problem further:


This is an excerpt from a larger project where I have a similar problem.

It looks similar to this question, ERC20 approve and transferFrom from a contract, except I'm doing approve outside and want the contract to just do transferFrom. It looks like there is a way to do transfer from a contract like this Open Zeppelin CrowdSale contract does and which I have working in my project. I like to be able to do either transfer or transferFrom from my own contract and like to better understand ownership and signature rules around it.

2 Answers 2


Problem solved thanks to debugging assistance from Gonçalo Sá. Here is the fix commit tl;dr: you have to approve the allowance first to the address of the contract calling tranferFrom and then transfer the value to the final destination address.


You could be suffering from the batch overflow bug. https://medium.com/@TokPie/erc20-tokens-under-attack-from-new-batchoverflow-bug-while-tokpie-remains-safe-b59dd716d469


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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