Solve truffle's "Could not find artifacts for import_path from any sources" problem

    When truffle is migrating the migrate contract, it sometimes reports "Could not find artifacts for "+ import_path +" from any sources"", as shown in Figure (1):


Figure (1) Report ZhouWuToken not found error

    In fact, it is because can not find the contract documents and error . Let's look at the third sentence: "Error: Could not find artifacts for ZhouWuToken from any sources" This line tells us that the contract file ZhouWuToken cannot be found. The following three places need to be modified:
    1) Under the project path/contracts, there must be a ZhouWuToken.sol file, as shown in Figure (2):

Figure (2) Change the name of the contract document to the full name, not abbreviated

    2) Project path/migrations/2_deploy_contracts.js, modify as follows:
//Project path/migrations/2_deploy_contracts.js

const ZhouWuToken = artifacts.require("ZhouWuToken");

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

    In the *.js of the migration contract, all are changed to the full name of Token , as shown in Figure (3):


Figure (3) In the .js of the migration contract, all must be changed to the full name of Token

    3) In the ZhouWuToken.sol file of the contract itself, the contract function should be named after the full name of the Token, namely contract ZhouWuToken, as shown in Figure (4):


Figure (4) The function name of the contract, use the full name of Token

Guess you like

Origin blog.csdn.net/sanqima/article/details/109150618