3

I am new to smart contract development and I am trying to deploy my first contract. When running the truffle compile for the first time I can see that a build folder was generated on my project however after running truffle migrate the artifacts are not being generated inside the build folder.

xxxs-iMac dApp % truffle compile


Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

Other threads suggest a problem with writing permission however since the folder build is being created I assume this is not the issue. This is the first time I am deploying a smart contract so I also think it maybe something on my dev setup although i have correctly installed truffle and ganache dependencies via npm.

Truffle config :

    module.exports = {
    networks: {
        development: {
            host: "127.0.0.1",
            port: 8545,
            network_id: "*", // Match any network id
        },
    },
    plugins: ["solidity-coverage"],
};

2_deploy_contracts.js file:

const Voting = artifacts.require("./Voting");

module.exports = function (deployer) {
    deployer.deploy(Voting);
};
5
  • please post the Error you got during migration! Commented Nov 19, 2020 at 6:30
  • Have you modified the 2_deploy_contracts.js file?
    – alberto
    Commented Nov 19, 2020 at 9:45
  • @alberto yes I modified the 2_deploy_contracts.js file. I updated the thread above with the code.
    – dhequex
    Commented Nov 20, 2020 at 5:35
  • @MYANZIKshrestha thank you for the reply. I did not get any error during the migration. It simply returned : Compiling your contracts... =========================== > Everything is up to date, there is nothing to compile. Network up to date. No artifacts were created although the build folder was created.
    – dhequex
    Commented Nov 20, 2020 at 5:37
  • It seems your migration code was not executed. Make sure you properly imported contracts in migration and try running ‘’’truffle migrate —reset’’’ Commented Nov 20, 2020 at 5:50

5 Answers 5

1

Most probably truffle cannot find where the contracts are.

You can define the location of the contract in the truffle-config.js with the following param:

contracts_directory: './contracts',
1
  • Thank you for that, this was my problem. Commented Oct 4, 2022 at 6:29
0

Please check your compiler version. Then make contract and compiler version the same. If you are working with react follow these steps:

  1. Check solidity smart contract version from top of your contract (eg. pragma solidity ^0.5.16)
  2. Check compiler version if it is greater or less than the contract version change the version of the compiler (from VS code, right click in the contract file and then select "change workspace compiler version)
  3. Then remove the node module from your project directory
  4. Now reinstall nodule module (npm install)
  5. Now migrate contract (truffle migrate --reset)
  6. Start the project (npm start)
1
  • This is a truffle-related issue, so probably addressed with point 5 only (no need to reinstall all modules...) Commented Jan 2, 2021 at 8:38
0

Check where your contracts are. They should be under the "contracts" directory in order for truffle to find the contracts. The "contracts" directory should not be under any sub directory, otherwise you have to explicitly mention it in the truffle-config.js

0

Try deleting your generated ABIs in /src/abis. After that, run truffle compile --all.

0

Truffle isn't able to find the location of the contracts folder. You have to add the below line in truffle-config.js file:

contracts_directory: './contracts'

After that again execute truffle compile, and it will create artifacts in build\contracts folder.

enter image description here

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.