0

build/contracts/HelloWorld.json

line 890:

"source": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.7;\r\n\r\ncontract HelloWorld{\r\n function hello() public pure returns(string memory){\r\n return 'hello world';\r\n }\r\n}",

I wrote that code at start, in contracts/HelloWorld.sol ,than i changed it:

HelloWorld.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

contract HelloWorld{

    string public message;

    constructor(string memory _message){
        message = _message;
    }


    function hello() public view returns(string memory){
        return message; 
    }

    function setMessage(string memory _message) public{
        message = _message;
    }

}

migrations/2_hello_world_migration.js

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

module.exports = function (deployer) {
  deployer.deploy(HelloWorld,"Hello world constructor");
};

when im typing

  1. truffle compile
  2. truffle develop
  3. migrate
  4. let instance = await HelloWorld.deployed()
  5. instance.hello() -> returning me 'hello world', from first build/migration
  6. instance.message() -> Uncaught TypeError: instance.message is not a function
  7. instance.setMessage('blah') -> Uncaught TypeError: instance.setMessage is not a function
2
  • migrate --reset doesn't help too Aug 23 at 11:30
  • Try deleting or renaming the whole build/ directory.
    – Ismael
    Aug 25 at 17:22

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.