Skip to content

A barebones Hello World repo for the Metacrafters Intermediate Solidity course

Notifications You must be signed in to change notification settings

jeffryan-POL/solidity_starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello World! in Solidity

Install

  1. Install Node.js

    Download and install from the official site.

  2. Install Truffle

    npm install -g truffle

Initialize

  1. Initialize Truffle in your project folder

    truffle init

    After initialization, you will find two folders called contracts and migrations. Contracts go in the contracts folder while contract deployment settings go in migrations.

  2. 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!";
    }   
  3. 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);
    }
  4. 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 simply migrate.

  5. 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!'

About

A barebones Hello World repo for the Metacrafters Intermediate Solidity course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published