Code Examples
Comprehensive examples showcasing real-world Omne blockchain applications. From simple payments to complex DeFi protocols, learn by doing.
Quick Start Examples
💳 Simple Transfer
Send OMNE tokens between accounts with automatic fee calculation.
import { OmneClient, Account } from '@omne/sdk'
const client = new OmneClient({ network: 'testnet' })
const account = await Account.fromPrivateKey(privateKey)
const result = await client.transfer({
from: account.address,
to: 'omne1recipient...',
amount: '1000000', // 1 OMNE
memo: 'Payment for services'
})
console.log('Transaction:', result.hash)
📊 Balance Check
Query account balances and transaction history.
import asyncio
from omne_sdk import OmneClient
async def check_balance():
client = OmneClient(network='testnet')
balance = await client.get_balance('omne1address...')
print(f"Balance: {balance.amount} {balance.denom}")
# Get transaction history
history = await client.get_transactions('omne1address...')
for tx in history:
print(f"{tx.type}: {tx.amount} at {tx.timestamp}")
asyncio.run(check_balance())
🔐 Multi-Signature
Create transactions requiring multiple signatures for enhanced security.
package main
import (
"github.com/omne-foundation/omne-go-sdk/client"
"github.com/omne-foundation/omne-go-sdk/multisig"
)
func main() {
// Create 2-of-3 multisig account
accounts := []*account.Account{account1, account2, account3}
multisigAddr := multisig.CreateAddress(accounts, 2)
// Create transaction
tx := &transactions.TransferTx{
FromAddress: multisigAddr,
ToAddress: "omne1recipient...",
Amount: "5000000", // 5 OMNE
}
// Sign with required accounts
signedTx := multisig.Sign(tx, account1, account2)
result, _ := client.Broadcast(ctx, signedTx)
}
📡 Real-time Events
Subscribe to blockchain events and real-time notifications.
// Subscribe to new blocks
const blockStream = client.subscribeToBlocks()
blockStream.on('block', (block) => {
console.log(`New block #${block.height}`)
console.log(`Transactions: ${block.txCount}`)
})
// Subscribe to account transactions
const txStream = client.subscribeToTransactions(accountAddress)
txStream.on('transaction', (tx) => {
console.log(`${tx.type}: ${tx.amount} OMNE`)
if (tx.type === 'receive') {
console.log(`Received payment from ${tx.sender}`)
}
})
Example Categories
Payment Processing
E-commerce payments, subscriptions, escrow, and payment streaming examples.
Token Creation
Custom tokens, NFTs, governance tokens, and tokenomics implementation.
DeFi Integration
Lending protocols, DEX integration, yield farming, and liquidity management.
Python Examples
Django integration, FastAPI backends, data analysis, and automation scripts.
Go Examples
High-performance services, microservices, CLI tools, and blockchain indexers.
TypeScript Examples
React dApps, Next.js integration, Node.js backends, and browser wallets.
Featured Integration
E-commerce Payment Gateway
Complete payment processing solution with React frontend and Node.js backend.
Community Examples
NFT Marketplace
CommunityFull-featured NFT marketplace with minting, trading, and royalty distribution.
DAO Governance
CommunityDecentralized autonomous organization with proposal voting and treasury management.
Development Resources
🛠️ Developer Tools
- • Testnet faucet for free tokens
- • Block explorer for debugging
- • Transaction simulator
- • Gas estimation tool
📚 Learning Path
- • Start with simple transfers
- • Learn smart contract deployment
- • Explore DeFi patterns
- • Build production applications
🤝 Community Support
- • Discord developer channel
- • Weekly developer calls
- • GitHub discussions
- • Example contribution program