I'm using a method in which transferfrom method of an ERC20 token is called. In test enn I use my own ERC20 token and ganache and everything works fine. but in Rinkeby testnet when I use interface of ERC20 and address of Deplyoed tokens in Rinkeby I get the error.
here is my deposite function :
function deposit(uint _value, IERC20 _currency) public {
require(_currency.transferFrom(msg.sender , address(this), _value), "transferFrom failed");
}
}
in my web3 I call approve function first(and wait for get mined) and then call deposit, every thing works fine in Ganache, but in Rinkeby, I always get my deposit reverted.
web3 code:
ERCInstance.methods.approve('deposit contract address', token amount).send({from:
accounts[0]}).on('transactionHash', (hash) => {
dipositeContractInstance.methods.deposit(amount, 'ERC address').
send({from: accounts[0]}).on('receipt', function(receipt){
});
note that I used pre created ERC20 tokens in rinkeby and even created my own one, but still get revert. for example rinkeby dai address is :'0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735'