I am following the official Truffle docs to create a Dapp and am reviewing the code. I am repeatedly seeing the line

var meta = MetaCoin.deployed();

What is the deployed function? What does it return?

| improve this question | | | | |
  • Why don't you do a console.log(meta); and see for yourself? – niksmac Nov 16 '16 at 5:18
  • 1
    I did that and I understand now. Thank you for helping me understand vs. just learning. – user5135 Nov 18 '16 at 4:01

The Truffle example test has:

// Get a reference to the deployed MetaCoin contract, as a JS object.

var meta = MetaCoin.deployed();

deployed is only in Truffle and it's a helper/shortcut so that you don't need to deal directly with the ABI and the address that your contract was deployed to. It's like these steps in web3.js:

var MyContract = web3.eth.contract(<abiArray>);
var contractInstance = MyContract.at(<address>);

Truffle has config files so it knows what the ABI and address of the contract is.

| improve this answer | | | | |

Your Answer

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