2

I am new to the truffle framework. I have initialised my contract Dapp with the constructor function as given below

pragma solidity ^0.5.0;

contract Dapp {
    uint public totalSupply;

    constructor() public {
        totalSupply = 1000000;
    }
}

and my migrations file in regards with the contract is

const Dapp = artifacts.require("Dapp");

module.exports = function(deployer) {
  deployer.deploy(Dapp);
};

I have compiled and migrated using the command truffle compile and truffle migrate, which results in successful compilation.

But when accessing the contract in truffle console like

let instance = await Dapp.deployed()

It results in ReferenceError: Dapp is not defined, I cannot able to figure out what went wrong. Is there any possible solution to this. And yeah I have followed the latest Truffle documentaion.

Documentation link for migration and interacting with truffle console.

My Network is in development mode which is given below

networks: {
    development: {
     host: "127.0.0.1",     // Localhost (default: none)
     port: 7545,            // Standard Ethereum port (default: none)
     network_id: "*",       // Any network (default: none)
    },
}
1

Okay change your port at truffle-config.js in the network section to 9545 for truffle develop environment. The reason why you can read at here: https://truffleframework.com/docs/truffle/getting-started/using-truffle-develop-and-the-console in the truffle develop section

This will spawn a development blockchain locally on port 9545, regardless of what your truffle-config.js configuration file calls for

  • I have tried that too, its not working – Thananjaya S Mar 22 at 10:37
  • I think you should post this question on truffle github as an issue maybe they will help you better – haxerl Mar 22 at 16:16
  • yea I will post this as an issue in truffle GitHub profile. Thanks for the response – Thananjaya S Mar 23 at 16:25
  • sorry we cant do much – haxerl Mar 23 at 16:47
  • It's okay, sir. I will try in GitHub. – Thananjaya S Mar 23 at 16:53
0

Apologies for not being able to comment instead of adding a new answer. I wonder if you somehow migrated contracts to Ganache (or a testnet), then tried to access it in Truffle Develop blockchain.

Could you upload a minimal repo to Github so that we reproduce the issue?

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.