1

I am trying to compile a sample solidity contract,sampleapp.sol. The code is given below:

pragma solidity >=0.4.21 <0.6.0;

contract SimpleStorage {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}

The migration code is given below:

pragma solidity >=0.4.21 <0.6.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;
  }

  function upgrade(address new_address) public restricted {
    Migrations upgraded = Migrations(new_address);
    upgraded.setCompleted(last_completed_migration);
  }
}

The code for migration code js is given below (file 1_initial_migration.js):

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

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

The error i am geting is: enter image description here

I am making this app over Eleven01 protocol. I have added their custom RPC in the Metamask. Please let me know if you require further details. Any help is appreciated.

2 Answers 2

1

Maybe you should keep the name of the file consistent with the contract name. sampleapp.sol

pragma solidity >=0.4.21 <0.6.0;

contract Sampleapp {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}
1
  • @Kartikey yeah,NP!
    – skyge
    Mar 17, 2019 at 8:48
0

As mentionned in truffle documentation your should create a new file for each migration.

But i think your main issue come from the ./ in your migration file.

Try like that.

1_initial_migration.js

const Migrations = artifacts.require("Migrations.sol");

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

2_sampleapp_migration.js

const sampleapp = artifacts.require("sampleapp.sol");

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.