Hope Foundation’s
Finolex Academy of Management and Technology, Ratnagiri
Department of Computer Science and Engineering (AI&ML)
Subject name: Blockchain Lab Subject Code: CSDOL7022
Class : BE Semester –VII Academic year: QUIZ SCORE:
2025-2026
Roll No 55 Experiment No. 01
Title: Introduction to Truffle, establishing local Blockchain using Truffle
1. Lab objectives applicable: LOB1
2. Lab outcomes applicable: LO1
3.Learning Objectives:
1. Develop and test smart contracts on local Blockchain.
4. Practical applications of the assignment/experiment:
5. Prerequisites: Hash function
6. Hardware Requirements:
A Computer system
7. Software Requirements:
● Windows 10/11 x64,
● NodeJS v12 or higher
● Visual Studio C++ Build Tools 2017 or higher
● Python 2.7 or higher
9. Experiment/Assignment Evaluation:
Sr. Parameters Marks Out of
No. obtained
1 Technical Understanding (Assessment may be done based on Q & 6
A or any other relevant method.) Teacher should mention the
other method used -
2 Neatness/presentation 2
3 Punctuality 2
Date of performance (DOP) Total marks obtained 10
Signature of the faculty
Step 1: Install Prerequisites
Install Node.js & npm
Download and install from https://nodejs.org
Install the tools via npm:
Open a NEW PowerShell prompt as Administrator (to ensure that it reloads), then run the
following commands:
$ npm install -g npm
Verify by running in terminal:
node -v
npm -v
Install Visual Studio Code (VSCode)
Download and install from https://code.visualstudio.com
Install Visual Studio extensions
Go into the extensions section, then install these plugins:
● Solidity
● Truffle for VS Code
Install Git (optional but recommended)
Download from https://git-scm.com/downloads
Configure PowerShell Execution Policy (for running npm/truffle scripts)
Open PowerShell as Administrator and run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
This allows scripts to run temporarily in the current session.
Step 2: Open VSCode & Create a New Project Folder
1. Open VSCode.
2. Create a new folder (e.g., hello-truffle) on your system.
3. Open the folder in VSCode:
File → Open Folder → select your folder.
Step 3: Initialize a Truffle Project
1. Open VSCode integrated terminal:
View → Terminal or `Ctrl + `` (backtick)
Run the following to install Truffle globally if not installed:
npm install -g truffle
2. If you get an execution policy error, run the Step 1 PowerShell command again.
Initialize a new Truffle project inside your folder:
truffle init
This will create folders like contracts/, migrations/, test/, and a config file
truffle-config.js.
Step 4: Write Your First Smart Contract
1. In the contracts/ folder, create a file called HelloWorld.sol.
Paste the following Solidity code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract HelloWorld {
string public message;
constructor() {
message = "Hello, World!";
}
function greet() public view returns (string memory) {
return message;
}
}
Step 5: Create Migration Script
In the migrations/ folder, create a new file called 2_deploy_helloworld.js.
Add this code:
const HelloWorld = artifacts.require("HelloWorld");
module.exports = function (deployer) {
deployer.deploy(HelloWorld);
};
//PASTE FOLLOWING CODE IN truffle-config.js
module.exports = {
networks: {
develop: {
port: 9545,
network_id: "*",
},
compilers: {
solc: {
version: "0.8.20"
};
Step 6: Run Local Blockchain
Start Truffle’s local blockchain environment:
truffle develop
Step 7: Exit the Truffle console
Type .exit or press Ctrl + C twice
#OUTPUT:-