I am trying to send ERC20 token into an escrow contract so that it could transfer them to relevant stake holders. The part that I am stuck in is properly using the approve function.
From my escrow contract I created the following approve function:
function approveDeposit(uint amount) public returns(uint) {
return _tokenAddress.approve(address(this), amount);
}
For example when submitting approveDeposit(100)
, I was expecting that the it would first call the tokenContract
and then approve the contract to transferFrom
the owner 100 tokens in the form:
_allowed[owner][contract] = 100;
But when I debug in remix, it seems like _allowed[contract][contract]
is executed.
How exactly can I execute _allowed[owner][contract] = amount
instead of _allowed[contract][contract] = amount
?
approve()
. Step 2, they "execute" by sending a transaction to the receiving contract, which will rely ontransferFrom()
... hopefully the receiver has a sufficient allowance grab what they need from the sender.