We have a token contract A and an Escrow contract B. While transferring token from an address to contract B we are using transferFrom function which overridden from contract A. But in need to do the transfer , we have to call approve function on contract A. This works if we call the approve function directly from contract A. But if we are overriding the approve function just like transferFrom on contract B, it is failing. Could someone please explain how we can call approve from contract B itself.
If you want to approve tokens in the contract b to be moved by someone else, this will work. But if you want to approve tokens of user X to be moved by user Y from contract B this won't work. The issue is that calling approve from contract B will have as msg.sender and it will fail.
Hope this helps
The rule is: you can approve the future spending of your tokens only. This is assured checking implicitly that msg.sender be the owner of the tokens “approved”.
If Escrow B want to approve something, it can only approve tokens on Escrow B’s account (I.e. owned by the 0x... address at which the Escrow results deployed).
No other possibilities do exist (if we are talking about ERC20).
You should need that a forceTransfer function in the token contract 1) do exists; 2) is accessible by you; in order to be able to do something different.
Any function you write or find written or you design in the Escrow cannot do nothing different from the standard described above, because the tokens reside and are managed in the internal storage of the tokens contract only, by the tokens contract only. Outside of it you can only interact with it, but no tokens exit from their contract.