Truffle Cryptocurrency Tutorial

Developing a Sample Cryptocurrency

Build and deploy the sample MetaCoin cryptocurrency using Visual Studio Code, Node.js, Git, Solidity and the Truffle framework.

9 Tutorial sections
5 Core tools
2 Smart contract files
100 Test ETH per account

Tutorial Overview

This tutorial shows how to create a sample cryptocurrency using the Truffle framework. It begins with the development environment, then moves into project creation, smart contract compilation, deployment and testing.

Complete setup

Install the tools required for Ethereum development on Windows.

MetaCoin example

Use Truffle’s built-in MetaCoin project as the sample cryptocurrency.

Smart contract workflow

Compile Solidity contracts and generate JSON artifacts.

Local deployment

Deploy and test the contract inside the Truffle development blockchain.

Development Environment Requirements

Before creating MetaCoin, prepare the development environment with the following tools.

Visual Studio Code

Code editor for Solidity, JavaScript and project files.

Git

Source control and project management tool.

Node.js

JavaScript runtime required for npm and Truffle.

Truffle

Ethereum development, testing and deployment framework.

Why Visual Studio Code?

  • Excellent Git integration.
  • Works well with Truffle projects.
  • Supports Solidity extensions.
  • Available on Windows, macOS and Linux.

Installation Process

1. Install Chocolatey

Launch PowerShell as administrator and run the installation command.

PowerShell as Administrator
Set-ExecutionPolicy Bypass
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

2. Install Development Tools

Install VS Code, Git and Node.js
choco install visualstudiocode -y
choco install git -y
choco install nodejs -y

3. Install Truffle Framework

Install Truffle globally
npm install -g truffle
Important: Close and reopen PowerShell after each installation step so the command path is refreshed.

Key Technologies Overview

Git

Tracks code changes and helps manage development projects.

Node.js

Runs JavaScript tools and packages required by Ethereum development workflows.

Truffle Framework

Provides project structure, compilation, migration, testing and debugging features.

Solidity

Contract-oriented programming language used to implement Ethereum smart contracts.

Check Your Installation

Verify installed tools
node -v
npm -v
truffle --version

Configuring VS Code for Blockchain Development

1. Create the Project Directory

Create folder and open VS Code
mkdir TruffleTest
cd TruffleTest
code .

2. Install Essential Extensions

  • Solidity: Smart contract development support.
  • Material Icon Theme: Better file and folder visualization.
Pro tip: The command code . opens Visual Studio Code in the current folder.

Creating Your First Blockchain Application

Sample MetaCoin Cryptocurrency

MetaCoin is a sample cryptocurrency project included with Truffle. It is useful because it gives you a ready-made contract structure for learning compilation, deployment and testing.

Create the MetaCoin project
truffle unbox metacoin

Generated Files

MetaCoin.sol

The main sample cryptocurrency contract.

ConvertLib.sol

A Solidity library used for currency conversion.

What is the EVM?

The Ethereum Virtual Machine is the runtime environment that executes smart contracts. It allows contract code to run in a decentralized and deterministic way across Ethereum nodes.

Compiling Smart Contracts

Compilation converts Solidity source code into artifacts that can be deployed to Ethereum-compatible networks.

Compile the MetaCoin contracts
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
truffle compile
Alternative: Use truffle.cmd compile if you encounter command errors on Windows.

Compilation Results

After successful compilation, a new build folder appears containing:

  • ConvertLib.json — compiled library artifact.
  • MetaCoin.json — compiled main contract artifact.
  • Migrations.json — deployment script artifact.

Success Indicator

If the JSON files appear in the build folder, the contract has compiled successfully.

Deploying and Testing the Contract

Launch Truffle Development Environment

Start Truffle Develop
truffle develop

Truffle Development Environment Features

  • 10 pre-configured accounts.
  • 100 ETH per account for local development.
  • Private keys provided for test accounts.
  • A simulated blockchain for safe experimentation.

Deploy the Contract

Inside the Truffle console
migrate

Test the Contract

Inside the Truffle console
test
To exit the Truffle console, use Ctrl + D.

Development Flow

Install tools
Unbox MetaCoin
Compile contracts
Start Truffle Develop
Migrate and test

Summary

What You Have Accomplished

Environment Setup

Installed Chocolatey, Visual Studio Code, Git, Node.js and Truffle.

Smart Contract Project

Created the sample MetaCoin cryptocurrency project.

Compilation

Compiled Solidity contracts into deployable JSON artifacts.

Local Deployment

Deployed and tested the contract inside Truffle Develop.

Advanced Topics to Explore Next

  • Web3 integration.
  • Transaction debugging.
  • Multi-network deployment.
  • Balance checking.
  • Mainnet or testnet deployment.
  • Custom token features.