I initalised a new truffle project by using truffle init
.
I changed the solc version to ^0.6.0 in the truffle-config.js file.
I ran truffle compile
and got this error:
TypeError: Error parsing C:/init-truffle/contracts/Migrations.sol: Cannot read property 'addFunction' of undefined
at runWithReadCallback (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\solc\wrapper.js:37:1)
at compileStandard (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\solc\wrapper.js:78:1)
at Object.compileStandardWrapper (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\solc\wrapper.js:85:1)
at Object.parseImports (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\parser.js:47:1)
at Object.getImports (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:374:1)
at Promise.all.then.results (C:\Users\Lino\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-compile\profiler.js:346:1)
Truffle v5.0.5 (core: 5.0.5)
Node v10.16.3
Here is the Migration.sol file:
pragma solidity >=0.4.21 <0.7.0;
contract Migrations {
address public owner;
uint public last_completed_migration;
constructor() public {
owner = msg.sender;
}
modifier restricted() {
if (msg.sender == owner) _;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
}
Here is the 1_initial_migration.js file:
const Migrations = artifacts.require("Migrations");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
Does anyone know what to do? This file compile without any problems with solc version set to ^0.5.0.
Environment:
- Operating System: Windows 10
- Truffle v5.0.5 (core: 5.0.5)
- Node v10.16.3
Thanks
truffle init
I modified noting more than the solidity compiler version, so there is no web3js code.