Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 454
kasper Avatar asked Sep 20 '25 20:09

kasper


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.

like image 80
Mikko Ohtamaa Avatar answered Sep 23 '25 12:09

Mikko Ohtamaa