-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Migrations = artifacts.require("Migrations"); | ||
|
||
module.exports = function (deployer) { | ||
deployer.deploy(Migrations); | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
}; |
67b6a77
There was a problem hiding this comment.
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:
Exiting: Review successful transactions manually by checking the transaction hashes above on Etherscan.
i got a this type of error what i do..?
67b6a77
There was a problem hiding this comment.
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.
67b6a77
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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", }
67b6a77
There was a problem hiding this comment.
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
67b6a77
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i got this error when i try this command "truffle migrate"
`
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\hassa\OneDrive\Desktop\Projects\blockchain\faucet\truffle-config.js from C:\Users\hassa\AppData\Roaming\npm\node_modules\truffle\node_modules\original-require\index.js not supported.
truffle-config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename truffle-config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in C:\Users\hassa\OneDrive\Desktop\Projects\blockchain\faucet\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
Truffle v5.11.5 (core: 5.11.5)
Node v20.17.0
`
67b6a77
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problem soved
just remove type : ''module'' from your package.json file