-
Initialize Truffle in your project folder
truffle init
After initialization, you will find two folders called
contracts
andmigrations
. Contracts go in thecontracts
folder while contract deployment settings go inmigrations
. -
The "Hello World!" contract
This is an example of a "Hello World!" contract in Solidity. "HelloWorld.sol" in
contracts
contains the following code:// SPDX-License-Identifier: MIT // compiler version must be greater than or equal to 0.8.17 and less than 0.9.0 pragma solidity ^0.8.17; contract HelloWorld { string public greet = "Hello World!"; }
-
Prepare the migration
"2_deploy_migration.js" in
migrations
contains the following code:var HelloWorld = artifacts.require("HelloWorld"); module.exports = function(deployer) { deployer.deploy(HelloWorld); }
-
Start Truffle console in development mode
truffle develop
In the Truffle console, execute
compile migrate
If you want to remigrate existing contracts, run
migrate --reset
instead of simplymigrate
. -
Test your contract
In the interactive Truffle console, run the following commands:
let instance = await HelloWorld.deployed() instance.greet()
Then you will see:
'Hello World!'
-
Notifications
You must be signed in to change notification settings - Fork 20
jeffryan-POL/solidity_starter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A barebones Hello World repo for the Metacrafters Intermediate Solidity course
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published