Skip to content

Commit

Permalink
Truffle init
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerga99 committed Aug 15, 2021
1 parent 2981bc2 commit 67b6a77
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
19 changes: 19 additions & 0 deletions contracts/Migrations.sol
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract Migrations {
address public owner = msg.sender;
uint public last_completed_migration;

modifier restricted() {
require(
msg.sender == owner,
"This function is restricted to the contract's owner"
);
_;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
}
5 changes: 5 additions & 0 deletions migrations/1_initial_migration.js
@@ -0,0 +1,5 @@
const Migrations = artifacts.require("Migrations");

module.exports = function (deployer) {
deployer.deploy(Migrations);
};
Empty file added test/.gitkeep
Empty file.
16 changes: 16 additions & 0 deletions truffle-config.js
@@ -0,0 +1,16 @@


module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
}
},
compilers: {
solc: {
version: "0.5.1", // Fetch exact version from solc-bin (default: truffle's version)
}
}
};

4 comments on commit 67b6a77

@alagusundaramramesh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Migrations" hit an invalid opcode while deploying. Try:

  • Verifying that your constructor params satisfy all assert conditions.
  • Verifying your constructor code doesn't access an array out of bounds.
  • Adding reason strings to your assert statements.

Exiting: Review successful transactions manually by checking the transaction hashes above on Etherscan.
i got a this type of error what i do..?

@aruns05
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run truffle migrate it is not deploying contract.

@KhirovSasha
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run truffle migrate it is not deploying contract.

I think its problems with the solidity version. The version of your contract should be the same as in truffle-config.js
in contract -> pragma solidity ^0.8.19;
in truffle-config.js -> solc: { version: "0.8.19", }

@AhsanHafeez2525
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I face same issue,

Try change your pragma and solc version

Migrations.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

truffle-config.js

compilers: {
solc: {
version: "0.5.1"
}
Sometimes, solc works for me with 0.8.20 or 0.7.3

Please sign in to comment.