Intelligent Contracts
CLI Deployment

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 TypeCLI ExampleNotes
str"Hello World"Use quotes for multi-word strings
int42Numbers without quotes
float3.14Decimal numbers
booltrue or falseLowercase boolean values
listNot supportedUse 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

  1. Prepare your contract: Ensure your .py file is ready
  2. Choose your network: Use genlayer network to set the target
  3. Deploy: Run the deploy command with appropriate arguments
  4. 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