I have a deployed contract (contract A) which should act as a storage (let's say 0xD7ACd2a9FD159E69Bb102A1ca21C9a3e3A5F771B).
Now from my ERC20 Token contract (contract B), I am calling approve to the contract A to allow it to "withdraw" my tokens.
Would it be possible to call trasnferFrom of contract A inside another function of contract B?
I am trying with (inside the code of B)
address A = 0xD7ACd2a9FD159E69Bb102A1ca21C9a3e3A5F771B;
...
approve(A,_amount);
A.call(bytes4(keccak256("transferFrom(address, address, uint256)")), (_B, msg.sender, _amount));
But it doesn't work since I am giving too many arg to the call function.
What would be the best way to transfer automatically my token (contract A) to a deployed ERC20 contract from within the contract B itslef?
EDIT
So on my receiver contract A, I added the function:
function getTokens (address from, uint256 value) public returns (bool) {
transferFrom(from, address(this), value);
return true;
}
And on my sender contract B I am calling:
address contract_address = 0x09943Fa8DD32C76f7b880627a0F6af73e8f5A595 ;
...
approve(contract_address, _value);
contract_address.call(abi.encode("getTokens(address, uint256)",msg.sender, _value));
...
But even if tx is succesfull, when I check balance of contract A, it's 0. I don't know exactly what I am missing.
balanceOf
and not justbalance
?