0
votes

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
1
migrate --reset doesn't help too - Омар Меджидов
Is the contract compiling correctly. First you have to confirm this. Save any changes in contract properly and then compile. Truffle console tells you if anything has changed by successfully compiling the contracts and if nothing was changed then it will give Everything is up to date, there is nothing to compile message - Taimoor

1 Answers

0
votes

truffle compile --all.

Or just try to delete the filepath build/