0

I have found this sample from udemy course

https://github.com/acloudfan/Blockchain-Course-Basic-Solidity/blob/93ca256bcf8c436c144425291257dcff5c3b269f/test/TestMetacoin.sol#L10

It uses the DeployedAddress.Metacoin() and pass it to a constructor of the Contract class, what is happening in here? I tried to look and google for ways to create a contract instance but to no luck I am getting an information about this. What I am reading is using deployed() as a way to get the instance, etc specialy during the unit test.

Is this a valid way to create a contract instance using the deployed contract address? Or is all of this just happening locally and not send to a network/node or something?

0

This code doesn't create nor deploy a contract. It takes the address of the deployed instance and casts to the contract type. MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());

DeployedAddresses is a library created after running the migrations scripts (see details here https://github.com/trufflesuite/truffle/blob/develop/packages/resolver/lib/sources/truffle/Deployed.ts#L10-L51). There one function for every deployed contract that returns its address.

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.