How to get the address of erc-20 token contract from token instance

Viewed 1886

i create instance of IERC20 public token in some contract.

How can i get the same address of token contract from the instance? token.this? token.address?

1 Answers

All contract objects can be casted as an address in Solidity:

const address myAddres = address(myContract);

However usually you do not need to do this, but you can pass the IERC20 object as is between functions.

Related