How to get the address of a contract inside a contract

ronenlhronenlh Member Posts: 4
e.g. I have a Token contract instantiated inside a Crowdfund contract. So that way, when somebody sends Ether I add tokens to his account in the Token contract.

However, how to I then interact with the Token contract? How do I get its address?

The token is instantiated in the constructor as token = new Token(); , that token is imported as import './Token.sol'; The Token's constructor has no arguments.



  • ronenlhronenlh Member Posts: 4
    I just understood this. When a contract creates a contract with the new keyword it returns the address, so it has to be stored (or explicitly converted from the class instance). However when a contract calls another contract (without the new keyword), we have to supply with address in the constructor, such as: token = Token(_address);. That's what I've been looking for.
Sign In or Register to comment.