1

I was going through following example in Solidity and came across this contract and I am confused if its a datatype like uint string as it is mentioned in comments as contract type what contract types are and why they are not recommended to create contracts

contract OwnedToken {
// TokenCreator is a contract type that is defined below.
// It is fine to reference it as long as it is not used
// to create a new contract.
TokenCreator creator;
address owner;
bytes32 name;
3

There is no special meaning to the name "TokenCreator", that is simply the name of a contract in that example code. In that code you will see there are two contracts defined, OwnedToken and TokenCreator.

The usage of the code TokenCreator creator; is creating a variable named "creator" which is of type "TokenCreator" which is the name of a contract defined in the code.

This variable can then be used to call the methods of the instantiated TokenCreator contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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