I am trying to learn Truffle tool using the tutorial at: Truffle tutorial

I am writing the following command at Truffle console to create an instance of the deployed contract but I am getting the message "undefined":

Victim.deployed().then(contract => victim = contract)


truffle(ganache)> truffle version

Truffle v5.1.27 (core: 5.1.27)

Solidity v0.5.16 (solc-js)

Node v8.10.0

Web3.js v1.2.1


Somebody please guide me how to create an instance of contract in Truffle Console?

  • What exactly is the problem with what you wrote? – goodvibration Jun 16 '20 at 5:00
  • Please open my question, I have corrected it. – zak100 Jun 16 '20 at 14:18
  • 1
    The Truffle-Console utility simply prints the value returned from the call. Since Victim.deployed().then(...) doesn't return anything, this utility prints undefined. It doesn't mean that the code in the callback function that you have passed to it (contract => victim = contract) has not been executed. – goodvibration Jun 16 '20 at 14:24
  • What is meant by the "then" part i.e. "(contract => victim = contract)", what is this operator "=>" and how the then part got associated with "Victim.deployed()" – zak100 Jun 17 '20 at 1:09
  • 1
    This is a Javascript question, so you should search it online (i.e., google it, and then click the first link to Stack Overflow). What to google? I guess, "what is => in javascript". In short, contract => victim = contract is equivalent to function (contract) {return victim = contract;}, which is essentially a function which takes one argument (contract). I guess you could also google "passing a function to another function in javascript". This question is not about Ethereum. – goodvibration Jun 17 '20 at 3:54

Your Answer

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

Browse other questions tagged or ask your own question.