Genlayer Builders Guide β Beginner Training Module
Overview
In this training, youβll learn how to:
-
Set up the Genlayer development environment
-
Initialize a local blockchain
-
Create and deploy your first intelligent contract
We will be deploying on Studionet, so make sure your setup matches the requirements below.
Prerequisites
Before starting, ensure you have the following installed:
-
Docker (for running blockchain services)
-
WSL (recommended for Windows users)
-
VS Code (code editor)
-
Rabby Wallet Extension (for interacting with blockchain)
-
Node.js (v18+) and npm
-
Python (v3.10+)
Tip: Verify installations:
node -v
npm -v
python --version
docker --version
Step 1 β Project Setup
1. Install Genlayer CLI
npm install -g genlayer
This installs the Genlayer command-line tool globally.
2. Create Your Project Folder
mkdir yourProjectName
cd yourProjectName
3. Create Contracts Directory
mkdir contracts
This folder will store your smart (intelligent) contracts.
Step 2 β Initialize the Blockchain
1. Initialize Genlayer
genlayer init
During setup:
You will be asked to:
-
Select an LLM provider β Choose Heurist AI
-
Enter API key
Get Heurist API Key
-
Use referral code:
genlayer
- Copy your API key and paste it into the CLI
Troubleshooting Docker Issues
If initialization fails:
Option 1 β Pull PostgreSQL manually
docker pull postgres:17-alpine
Option 2 β Pull required images manually
Use Docker Desktop UI or:
docker pull <missing-image-name>
2. Start the Blockchain
genlayer up
This starts:
-
Local blockchain
-
Database
-
AI execution environment
Step 3 β Create Your First Intelligent Contract
Now youβre ready to build your contract.
Official Documentation
Follow the official guide:
https://docs.genlayer.com/developers/intelligent-contracts/first-contract
Basic Contract Structure (Example)
Hereβs a simplified conceptual example:
from genlayer import Contract
class HelloWorld(Contract):
def __init__(self):
self.message = "Hello, Genlayer!"
def get_message(self):
return self.message
Deploy Your Contract
Typical deployment flow:
genlayer deploy contracts/HelloWorld.py
Then interact with it using:
genlayer call <contract-address> get_message
Key Concepts You Should Understand
1. Intelligent Contracts
Unlike traditional smart contracts, Genlayer contracts:
-
Can use AI (LLMs)
-
Can process natural language
-
Can make context-aware decisions
2. Local Blockchain
-
Runs in Docker
-
Simulates real deployment
-
Safe for testing
3. Studionet Deployment
Once tested locally:
-
Deploy to Studionet
-
Connect wallet (Rabby)
-
Interact via frontend or CLI
Best Practices
-
Always test locally before deploying -
Keep API keys secure -
Use version control (Git) -
Write modular contracts -
Log errors during development
Next Steps
After completing this training:
-
Build a more complex contract
-
Integrate a frontend (React / Next.js)
-
Connect Rabby Wallet
-
Deploy to Studionet
-
Experiment with AI-powered logic