Truffle Introduction

thank you man it helped but the course got updated lol :slight_smile:

yup all good now thanks!

Hi all, I love this course but I think I downloaded the wrong truffle version. The Truffle version I’m working with is v5.2.2 and the Soldity version is v0.5.16.
When I wanted to compile my contract it said this

Compiling your contracts...
===========================
> Compiling ./contracts/Functional.sol
> Compiling ./contracts/Storage.sol
> Compilation warnings encountered:

    /Users/sk/proxyContract/contracts/Functional.sol:1:1: Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.5.16;"

^
,/Users/sk/proxyContract/contracts/Storage.sol:1:1: Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.5.16;"

^

> Everything is up to date, there is nothing to compile.

I don’t know what I’ve to do to fix this, or is it good?
Tried to change the pragma solidity to

pragma solidity ^0.5.16;

but still the same error. Does anyone know what I’ve to do?

I thought I fixed it by updating Truffle, but after that was done both the Storage.sol and Function.sol was gone. Had to make the contracts again, but it still gives me the same error.
I tried searching the web for the answer, but didn’t find anything that can help me…

Hi @Sil

Post your contracts here and I will take a look, it seems like you’re missing the pragma statement.
These are warnings anyway so you should still be able to proceed.

Regards,
Dani

I think I know what went wrong. Is it possible that I have to save the contract before compiling it?

It now compiles the contract without any errors. Thanks again for helping me!!

anyway here’s the contracts!

pragma solidity ^0.5.16;

contract Storage {
  mapping (string => uint) _uintStorage;
  mapping (string => bool) _boolStorage;
  mapping (string => string) _stringStorage;
  mapping (string => bytes4) _bytesStorage;
  mapping (string => address) _addressStorage;
  address public owner;
  bool public _initialized;
}

pragma solidity ^0.5.2;

import "./Storage.sol";

contract Proxy is Storage {

  address currentAddress;

  constructor(address _currentAddress) public{
    currentAddress = _currentAddress;
  }
  function upgrade(address _newAddress) public{
    currentAddress = _newAddress;
  }

  //FALLBACK FUNCTION.
  function () payable external {


  }
}

pragma solidity ^0.5.2;

import "./Storage.sol";

contract Functional is Storage {

  modifier onlyOwner() {
    require(msg.sender == owner);
    _;
  }
  constructor() public{
    owner = msg.sender;
  }

  function getNumberOfDogs() public view returns (uint) {
    return _uintStorage["Dogs"];
  }
  function setNumberOfDogs(uint toSet) public{
    _uintStorage["Dogs"] = toSet;
  }
}

1 Like

Hey @Sil

If you made changes to your contract but you did not save, then Truffle was compiling the older version :slight_smile:

Cheers,
Dani

1 Like

When ever I want to link my truffle project to ganache
Whenever I click save and restart my ganache keep loading forever it not even saving it wat should I do. ?

I saved the file whenever I make changes but it still loading

The address in ganache after deployment,
Can we send fund to that address to fund the contract

Hi @beloved

You can surely send ether to your contract from your migration file :slight_smile:

Happy coding,
Dani

Pls I haven’t been able to deploy files properly without encountering this error

Hey @beloved

It is not compiling due to a syntax error, I am not sure if that’s in the code that you wrote or in a npm pkg.
Please follow this faq first and retry: FAQ - How to downgrade Node.Js

If that did not solve post your project on GitHub and share the link.

Cheers,
Dani

pragma solidity 0.5.12;

contract Hello {
string message = ā€œhiā€;
function get()public view returns(string memory){
return message;
}
function set(string memory newMessage) public{
message = newMessage;
}
}

here is the code it just a simple hello contract quiet similar to ur example

Hey @beloved,

Change the quotation marks in your string hi from ā€œ to " and try again.

Cheers,
Dani

1 Like

done that but still giving me error
but i think the error is coming from the javascript file pls check this out if it correct
const Hello = artifacts.require(ā€œHelloā€);

module.exports = function(deployer) {
deployer.deploy(Hello).then(function(instance){
instance.set(ā€œgoodā€).then(function(){
instance.get().then(function(message){
console.log(ā€œcurrent messageā€ + message);
});
});

});
});

1 Like

the quote is change in atom

1 Like

You can use the ā€œPreformatted Textā€ Button to encapsulate any kind of code you want to show.


function formatText(){

let words = ā€œI’m a preformatted Text box, Please use me wisely!ā€

}

prefromatted_text-animated

Carlos Z.

1 Like

Hi @beloved

By copy / pasting your migration file in a text editor it tells me that the past parenthesis should not be there.

const Hello = artifacts.require(ā€œHelloā€);

module.exports = function(deployer) {
deployer.deploy(Hello).then(function(instance){
instance.set(ā€œgoodā€).then(function(){
instance.get().then(function(message){
console.log(ā€œcurrent messageā€ + message);
});
});

});
}   -->>>>>>) ;

Delete it and compile.

You should also get this error from your editor, is atom showing it?

Also please follow the advise of @thecil so that you will be able to post a clear and formatted code :slight_smile:

Happy coding and keep us posted!
Dani

1 Like

Good morning sir it still giving me the synax error pls wat should I do I really need this knowledge

No error is being shown by atom