I have found this sample from udemy course


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?

1 Answer 1


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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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