0
contract Test {
  ERC721Token public tokenAddress;

  constructor(address _address) public {
    tokenAddress = ERC721Token(_address);
  }
}

In this example, I just tested tokenAddress returns the address of a ERC721Token contract. If it's just returning an address, how come the state variable tokenAddress's type is ERC721Token and not address?

and the line here, tokenAddress = ERC721Token(_address); What does ERC721Token(_address) mean? Does it mean it's searching a specific ERC721Token contract from the network?

1 Answer 1

1

Contract casting is only used for the compiler to know the functions available on the contract. Internally, you're right that tokenAddress is just an address, and ERC721Token(_address) isn't really doing anything other than allowing the compiler to know the functions.

Otherwise, the compiler would fail if you tried calling ERC721Token functions on a regular address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.