-1

ANSWER TO THIS QUESTION IS HERE : https://stackoverflow.com/questions/48044742/cannot-deploy-helloworld-contract-to-my-network-testrpc

pardon my basic question, bud what else do i need to deploy my contract?

I have simple Hello World contract defined as follows HelloWorld.sol:

pragma solidity ^0.4.17;

contract HelloWorld{  
    function sayHello() internal pure returns(string){
        return("Hello 2018!");
    }
}

Initial migrations.js:

var Migrations = artifacts.require("./Migrations.sol");
var HelloWorld = artifacts.require("./HelloWorld.sol");

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

And finally since im using truffle, truffle.js:

module.exports = {

  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    }
  }

};

When I run commands:

truffle compile
truffle migrate

Then go to console:

   truffle console

and i use js:

var hw
HelloWorld.deployed().then(function(deployed){hw=deployed;});

I get

Error: HelloWorld has not been deployed to detected network (network/artifact mismatch) at C:\Users\Kofola\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:317116:17 at at process._tickDomainCallback (internal/process/next_tick.js:228:7)

How do i correctly deploy my contract and test its method?

I should also add that my testrpc server is running at 8545 and everything seems to be alright. (all of this is running on localhost) I have tried to specify id of the network, i explicitly set id and specified it in truffle.js, still not working. I also tried to change visibility of the function.

  • Your truffle.js says "8545"; your comment at the end says "8548". Is it as simple as that? – benjaminion Dec 31 '17 at 18:18
  • @benjaminion Sorry , typo when typing question on my part. Its 8545. Problem still persist – Tomas Bisciak Dec 31 '17 at 18:19
  • I am running the same issue. Any luck with the Answer? – Shahzad Malik Feb 15 '18 at 15:25
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – Ismael Feb 15 '18 at 16:39
1

Run this on truffle console:

var hw = HelloWorld.at(HelloWorld.address);

Check the address:

hw.address

call your function:

hw.sayHello();

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.