0

Can anyone help me in understanding what is happening over here? I understand that the contract name is TestAdoption, but after that - what is the first word "Adoption"? The second word "adoption". I do acknowledge and note that my contract has been defined as "Adoption" - so the first word should be that contract. But then what is the variable being equated (set) to?

contract TestAdoption {
  Adoption adoption = Adoption(DeployedAddresses.Adoption());
  }

Here is the link, which I have been studying: http://truffleframework.com/tutorials/pet-shop

  • Adoption is the type of the variable. adoption is the variable. Adoption(...) casts the value to the type Adoption. DeployedAddresses.Adoption() is presumably a Truffle thing... that must return the address of the deployed contract. – smarx Jun 9 '18 at 7:31
0
Adoption adoption = Adoption(DeployedAddresses.Adoption());

The first keyword, Adoption, is just declaring the type of the variable (which in this case is an instance the "Adoption" contact which has been defined elsewhere).

The second, adoption, is just naming that variable. You could call it anything.

Then the function Adoption( someAddress ) is saying "retrieve the deployed instance of the Adoptioncontract at someAddress.

I'm not sure precisely what this does, DeployedAddresses.Adoption(), because you haven't defined DeployedAddresses anywhere in your question. But whatever it is, it will be returning the address of the deployed Adoption contract, because the Adoption() function takes an address as the argument.

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.