CLI Deployment
The GenLayer CLI provides a straightforward way to deploy contracts directly from the command line.
Direct Contract Deployment
Deploy a single contract using the deploy
command:
genlayer deploy --contract <contractPath> [options]
Options:
--contract <contractPath>
: Path to the Python contract file--rpc <rpcUrl>
: Custom RPC URL (optional)--args <args...>
: Constructor arguments (space-separated)
Basic Examples
Simple Contract Deployment
# Deploy a simple contract
genlayer deploy --contract contracts/my_contract.py
Contract with Constructor Arguments
# Deploy with constructor arguments
genlayer deploy --contract contracts/betting_contract.py --args "World Cup 2024" 1000
Deploy to Specific Networks
You can deploy to different networks by using the --rpc
option or by setting your default network:
# Deploy to localnet with custom RPC
genlayer deploy --contract contracts/my_contract.py --rpc http://localhost:4000/api
# Deploy to studionet
genlayer deploy --contract contracts/my_contract.py --rpc https://studio.genlayer.com/api
# Deploy scripts to specific network
genlayer deploy --rpc https://custom-network.com/api
Alternative: Set default network first
# Set network then deploy
genlayer network testnet-asimov
genlayer deploy --contract contracts/my_contract.py
Constructor Arguments
When deploying contracts with constructor parameters, provide them as space-separated arguments:
String Arguments
# Single string argument
genlayer deploy --contract contracts/my_contract.py --args Hello
Multiple Arguments
# Multiple arguments (string, number, boolean)
genlayer deploy --contract contracts/my_contract.py --args "Contract Name" 100 true
Multi-word Strings
# Multi-word strings (use quotes)
genlayer deploy --contract contracts/my_contract.py --args "Multi word string" 42
Argument Types
The CLI automatically handles different argument types:
Python Type | CLI Example | Notes |
---|---|---|
str | "Hello World" | Use quotes for multi-word strings |
int | 42 | Numbers without quotes |
float | 3.14 | Decimal numbers |
bool | true or false | Lowercase boolean values |
list | Not supported | Use deploy scripts for complex types |
⚠️
For complex data types like lists, dictionaries, or objects, use Deploy Scripts instead of CLI deployment.
Deployment Output
When a deployment succeeds, you'll see output similar to:
✅ Contract deployed successfully!
Transaction Hash: 0x1234567890abcdef...
Contract Address: 0xabcdef1234567890...
Quick Deployment Workflow
- Prepare your contract: Ensure your
.py
file is ready - Choose your network: Use
genlayer network
to set the target - Deploy: Run the deploy command with appropriate arguments
- Verify: Note the contract address for future interactions
# Example workflow
genlayer network localnet
genlayer deploy --contract contracts/token.py --args "MyToken" "MTK" 1000000
Next Steps
- Learn about Deploy Scripts for more complex deployments
- Configure networks with Network Configuration