Any ideas about the reason for the following error from truffle? The contract is from the solidity docs.
Truffle.js –
//var Set = artifacts.require("./Set");
var Consumer = artifacts.require("./Consumer");
var Infofeed = artifacts.require("./Infofeed");
//var med1 = artifacts.require("./med1");
module.exports = function(deployer) {
//deployer.deploy(Set);
//deployer.link(Set, d3);
deployer.deploy(Consumer);
deployer.deploy(Infofeed);
};
Code –
pragma solidity ^0.4.18;
contract InfoFeed {
function info() public payable returns (uint ret) { return 42; }
}
contract Consumer {
InfoFeed feed;
function setFeed(address addr) public { feed = InfoFeed(addr); }
function callFeed() public { feed.info.value(10).gas(800)(); }
}
Filename – Consumer.sol
Output –
Writing artifacts to ./build/contracts
Using network 'development'.
Running migration: 1_initial_migration.js
Replacing Migrations...
... 0x8a2f45296c97a1393b9ef1b21e63ba5616944f893b70fd84c589fcf66ec7a29e
Migrations: 0x9a57fa3522a99d6b8d19ecca976edc2168260580
Saving successful migration to network...
... 0xb232b7a1a42e1abf795f60686b00b301a346464c08ffbe2c0df5d955b195070e
Saving artifacts...
Running migration: 2_deploy_contracts.js
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:63957
throw new Error("Could not find artifacts for " + import_path + " from any sources");
^
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:63957
throw new Error("Could not find artifacts for " + import_path + " from any sources");
^
Error: Could not find artifacts for ./Infofeed from any sources
at Resolver.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:63957:9)
at Object.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176376:36)
at ResolverIntercept.require (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:305479:32)
at /geth/mybc/geth/zt/migrations/2_deploy_contracts.js:3:26
at ContextifyScript.Script.runInContext (vm.js:59:29)
at ContextifyScript.Script.runInNewContext (vm.js:65:15)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:204344:14
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
Best Answer
I got the same problem just now, but I solved it in this way.
After your compilation, go to
your_folder_location\build\contracts
folder.Then you will see a JSON file which not related to your contract file.
Just rename that JSON file same as your contract file. ( most probably that JSON file related your folder name )
But after that you can see the renamed file as well as the original file too, both files in same location. Don't worry.
That's it.