0

I'm working through a Solidity course on Udemy. I'm trying to run migrate on truffle.

Here's my code:

MyToken.sol

// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("Testing Token", "TST") {
        _mint(msg.sender, initialSupply);
    }
}

2_depoly_contracts.js

var MyToken = artifacts.require("MyToken");

module.exports = async function(deployer) {
    await deployer.deploy(MyToken, 1000000);

}

truffle-config.js

const path = require("path");

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
  contracts_build_directory: path.join(__dirname, "client/src/contracts"),
  networks: {
    develop: {
      port: 8545
    }
  },
  compilers: {
    solc: {
      version: "^0.8.0"
    }
  }

};

Here is the error I'm getting when running truffle:

2_deploy_contracts.js
=====================

/usr/local/lib/node_modules/truffle/build/459.bundled.js:27241
        throw new Error("Could not find artifacts for " + import_path + " from any sources");
        ^

Error: Could not find artifacts for MyToken from any sources
    at Resolver.require (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:60:1)
    at Object.require (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:172:1)
    at ResolverIntercept.require (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/ResolverIntercept.js:22:1)
    at /Users/macbookdbw/Dropbox/Personal/Solidity/TokenizeProject/migrations/2_deploy_contracts.js:1:25
    at Script.runInContext (vm.js:144:12)
    at Script.runInNewContext (vm.js:149:17)
    at Object.file (/usr/local/lib/node_modules/truffle/build/webpack:/packages/require/require.js:94:1)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:44:1)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.runAll (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
    at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:76:1)
    at Object.module.exports [as run] (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:44:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)

I've looked at these questions and I think I'm employing these answers (1, 2) , but still no luck.

What am I doing wrong?

1 Answer 1

0

This might be silly, but have you compiled your solidity file?

https://trufflesuite.com/docs/truffle/getting-started/compiling-contracts.html

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.