Smart contract development CLI for GLIN Network
glin-forge is the official command-line tool for developing, deploying, and interacting with ink! smart contracts on the GLIN Network. Inspired by tools like GitHub CLI (gh) and Hardhat, it provides a seamless developer experience for blockchain development.
- 🔨 Build & Test - Compile and test ink! smart contracts
- 🚀 Deploy - Deploy contracts to any network (testnet/mainnet/local)
- 📞 Interact - Call contract methods and query state
- 📝 TypeScript Generation - Auto-generate TypeScript types from ABI
- 🔍 Contract Verification - Verify contracts on block explorer
- ⚡ Gas Optimization - Built-in gas estimation and tips
- 🌐 Multi-network - Easy network switching (testnet, mainnet, local)
cargo install glin-forgegit clone https://github.com/glin-ai/glin-forge
cd glin-forge
cargo install --path .Download pre-built binaries from GitHub Releases:
- Linux (x86_64, ARM64)
- macOS (Intel, Apple Silicon)
- Windows (x86_64)
- Rust - Install from rustup.rs
- cargo-contract - Install with
cargo install cargo-contract --force - ink! - For writing smart contracts (optional)
# Create from ERC20 template
glin-forge new my-token --template erc20
cd my-tokenglin-forge buildglin-forge deploy \
--network testnet \
--account alice# Query (read-only, no gas)
glin-forge query 5ContractAddr... balanceOf 5Account...
# Call (transaction, costs gas)
glin-forge call 5ContractAddr... transfer 5Recipient... 1000 \
--account aliceglin-forge typegen --output ./frontend/src/typesCompile the ink! smart contract.
glin-forge build [OPTIONS]
Options:
-p, --path <PATH> Path to contract project [default: .]
--release Build in release mode
--verify Verify contract after buildingDeploy contract to a network.
glin-forge deploy [OPTIONS]
Options:
-w, --wasm <WASM> Path to WASM file
-m, --metadata <METADATA> Path to metadata JSON
-c, --args <ARGS> Constructor arguments (comma-separated)
-v, --value <VALUE> Value to send (in GLIN) [default: 0]
-n, --network <NETWORK> Network [default: testnet]
-a, --account <ACCOUNT> Deploying account
-g, --gas-limit <GAS_LIMIT> Gas limit override
--salt <SALT> Salt for deterministic deployment
-y, --yes Skip confirmation promptQuery contract state (read-only).
glin-forge query <ADDRESS> <METHOD> [ARGS]...
Arguments:
<ADDRESS> Contract address
<METHOD> Method name
[ARGS]... Method arguments
Options:
-n, --network <NETWORK> Network [default: testnet]
-m, --metadata <METADATA> Path to contract metadata
--json Output as JSONExample:
glin-forge query 5GrwvaEF... balanceOf 5Account... --jsonExecute contract transaction (state-changing).
glin-forge call <ADDRESS> <METHOD> [ARGS]...
Arguments:
<ADDRESS> Contract address
<METHOD> Method name
[ARGS]... Method arguments
Options:
-n, --network <NETWORK> Network [default: testnet]
-a, --account <ACCOUNT> Calling account
-v, --value <VALUE> Value to send [default: 0]
-m, --metadata <METADATA> Path to contract metadata
-g, --gas-limit <GAS_LIMIT> Gas limit override
-y, --yes Skip confirmation
--wait Wait for finalizationExample:
glin-forge call 5GrwvaEF... transfer 5Recipient... 1000 \
--account alice \
--network testnet \
--waitGenerate TypeScript types from contract ABI.
glin-forge typegen [OPTIONS]
Options:
-a, --abi <ABI> Path to ABI JSON
-c, --contract <CONTRACT> Contract address (fetch ABI from chain)
-o, --output <OUTPUT> Output directory [default: ./types]
-n, --network <NETWORK> Network [default: testnet]
--hooks Generate React hooksExample:
# Generate from local ABI
glin-forge typegen --abi ./target/ink/metadata.json --output ./frontend/src/types
# Generate with React hooks
glin-forge typegen --abi ./target/ink/metadata.json --hooksGenerated Output:
// Generated TypeScript interface
export interface MyTokenContract {
query: {
balanceOf: (account: string) => Promise<bigint>
totalSupply: () => Promise<bigint>
}
tx: {
transfer: (to: string, amount: bigint) => Promise<TxResult>
approve: (spender: string, amount: bigint) => Promise<TxResult>
}
}Upload WASM code without instantiation.
glin-forge upload --wasm contract.wasm --account aliceInstantiate contract from uploaded code hash.
glin-forge instantiate <CODE_HASH> --account alice --args 1000000Watch contract events in real-time.
glin-forge watch 5ContractAddr... Transfer --followVerify contract on block explorer.
glin-forge verify 5ContractAddr... \
--wasm contract.wasm \
--metadata metadata.json \
--network testnetManage network and account configuration.
# Set network RPC
glin-forge config set-network mainnet wss://rpc.glin.network
# Set default account
glin-forge config set-account alice
# View configuration
glin-forge config showManage networks.
# List networks
glin-forge network list
# Add custom network
glin-forge network add custom wss://my-node.com
# Switch network
glin-forge network use testnetManage accounts.
# Import account
glin-forge account import alice --keystore ./alice.json
# List accounts
glin-forge account list
# Export account
glin-forge account export aliceCheck account balance.
glin-forge balance 5GrwvaEF... --network testnetCreate glin-forge.toml in your project root:
[project]
name = "my-token"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
[contract]
path = "./lib.rs"
output = "./target/ink"
[networks.testnet]
rpc = "wss://testnet.glin.network"
explorer = "https://explorer-testnet.glin.network"
[networks.mainnet]
rpc = "wss://rpc.glin.network"
explorer = "https://explorer.glin.network"
[accounts]
alice = { keystore = "~/.glin/keystore/alice.json" }Available contract templates:
- erc20 - ERC20 token contract
- erc721 - NFT contract
- dao - Basic DAO governance
- multisig - Multi-signature wallet
- escrow - Escrow contract
Create from template:
glin-forge new my-project --template erc20# 1. Create new contract
glin-forge new my-token --template erc20
cd my-token
# 2. Build contract
glin-forge build --release
# 3. Deploy to testnet
glin-forge deploy \
--network testnet \
--account alice \
--args "1000000,MyToken,MTK" \
--value 1
# 4. Query total supply
glin-forge query <CONTRACT_ADDR> totalSupply
# 5. Transfer tokens
glin-forge call <CONTRACT_ADDR> transfer <RECIPIENT> 100 \
--account alice \
--wait
# 6. Generate TypeScript types
glin-forge typegen --output ./frontend/src/contractsAfter generating types:
import { useMyToken } from './contracts/useMyToken'
import { useContractTx } from '@glin-ai/sdk-react'
function TransferButton() {
const { contract } = useMyToken('5ContractAddress...')
const { execute, loading } = useContractTx({
contract,
method: 'transfer'
})
const handleTransfer = async () => {
await execute('5Recipient...', 1000n)
}
return (
<button onClick={handleTransfer} disabled={loading}>
Transfer
</button>
)
}Pre-configured networks:
| Network | RPC | Explorer |
|---|---|---|
| testnet | wss://testnet.glin.network |
https://explorer-testnet.glin.network |
| mainnet | wss://rpc.glin.network |
https://explorer.glin.network |
| local | ws://localhost:9944 |
- |
cargo install cargo-contract --forceCheck your network configuration:
glin-forge config showTest RPC connection:
glin-forge balance 5GrwvaEF... --network testnetManually specify gas limit:
glin-forge call ... --gas-limit 5000000000We welcome contributions! Please see CONTRIBUTING.md for guidelines.
# Clone repository
git clone https://github.com/glin-ai/glin-forge
cd glin-forge
# Build
cargo build
# Run tests
cargo test
# Install locally
cargo install --path .Apache-2.0 - see LICENSE for details.
- Documentation: https://docs.glin.ai/forge
- Discord: https://discord.gg/glin
- GitHub Issues: https://github.com/glin-ai/glin-forge/issues
- Twitter: @glin_ai
Built with ❤️ by the GLIN team