1

I tried solutions provided in ethereum stack, but nothing worked for me.

My smart contract file:

pragma solidity ^0.4.15;

contract Election {

    string public candidate;

    function Eletion () public {
        candidate = "Candidate 1";
    }
}

Migration file:

var Election = artifacts.require("./Election.sol");

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

Im getting the following Error

Using network 'development'.

Running migration: 2_deploy_contracts.js

C:\Users\jeevastella\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:59973 throw new Error("Could not find artifacts for " + import_path + " from any sources"); ^ C:\Users\jeevastella\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:59973 throw new Error("Could not find artifacts for " + import_path + " from any sources"); ^

Error: Could not find artifacts for ./Election from any sources at Resolver.require (C:\Users\jeevastella\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:59973:9) at Object.require (C:\Users\jeevastella\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:69602:36) at ResolverIntercept.require (C:\Users\jeevastella\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:197047:32) at C:\Users\jeevastella\Desktop\election\migrations\2_deploy_contracts.js:1:26 at Script.runInContext (vm.js:107:20) at Script.runInNewContext (vm.js:113:17) at C:\Users\jeevastella\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:101639:14 at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

2
  • 1
    construcor name should be same as the contract name
    – Aniket
    Nov 20, 2018 at 6:47
  • 1
    It clearly states that it can't find the contract. So either it's not in the current directory or it has different filename. Nov 20, 2018 at 9:23

2 Answers 2

1

Don't know if you still need the answer, but I fixed it by editing the migration file require path. Change it to in your case var Election = artifacts.require("Election") Then run migrate with --reset

1

Do verify that the name of smart contract is same as mentioned in the migration file.

Your Answer

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

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