Token Creation & Management

Learn how to create, deploy, and manage tokens on the Omne network. From simple utility tokens to complex tokenomics with governance features.

Basic Token Creation

ERC-20 Compatible Token

Create a standard fungible token compatible with ERC-20 interfaces for maximum ecosystem compatibility.

import { OmneSDK, TokenFactory } from '@omne/sdk' // Initialize the SDK const omne = new OmneSDK({ network: 'mainnet', // or 'testnet' privateKey: process.env.PRIVATE_KEY }) // Create a basic token async function createBasicToken() { const tokenFactory = omne.getTokenFactory() const tokenConfig = { name: "MyToken", symbol: "MTK", decimals: 18, initialSupply: "1000000", // 1M tokens maxSupply: "10000000", // 10M max supply mintable: true, burnable: true } try { const result = await tokenFactory.createToken(tokenConfig) console.log('Token created successfully!') console.log('Contract Address:', result.contractAddress) console.log('Transaction Hash:', result.transactionHash) console.log('Gas Used:', result.gasUsed) return result } catch (error) { console.error('Token creation failed:', error) throw error } } // Deploy the token createBasicToken() .then(result => { console.log('Token deployment complete:', result) }) .catch(console.error)

Advanced Token Features

Token with Governance

Create a governance token with voting capabilities and proposal mechanisms.

import { OmneSDK, GovernanceToken } from '@omne/sdk' async function createGovernanceToken() { const omne = new OmneSDK({ network: 'mainnet', privateKey: process.env.PRIVATE_KEY }) const governanceConfig = { name: "Governance Token", symbol: "GOV", decimals: 18, initialSupply: "100000", // Governance features votingDelay: 1, // 1 block votingPeriod: 45818, // ~1 week in blocks proposalThreshold: "1000", // 1000 tokens to create proposal quorumPercentage: 4, // 4% quorum required // Advanced features snapshot: true, // Enable snapshot voting delegation: true, // Allow vote delegation timelock: { enabled: true, delay: 86400 // 24 hours } } const governanceToken = new GovernanceToken(omne) const result = await governanceToken.deploy(governanceConfig) console.log('Governance token deployed:', result.contractAddress) // Create a sample proposal const proposal = await governanceToken.createProposal({ title: "Increase token rewards", description: "Proposal to increase staking rewards by 2%", targets: [result.contractAddress], values: [0], calldata: ["0x..."], // Encoded function call eta: Math.floor(Date.now() / 1000) + 86400 // 24 hours from now }) console.log('Proposal created:', proposal.proposalId) return { token: result, proposal } }

Multi-Token Factory

Deploy multiple tokens efficiently with batch operations and shared configurations.

import { OmneSDK, MultiTokenFactory } from '@omne/sdk' async function deployTokenSuite() { const omne = new OmneSDK({ network: 'mainnet', privateKey: process.env.PRIVATE_KEY }) const multiFactory = new MultiTokenFactory(omne) const tokenSuite = [ { name: "Utility Token", symbol: "UTIL", type: "ERC20", supply: "1000000", features: ["mintable", "burnable"] }, { name: "Governance Token", symbol: "GOV", type: "ERC20Votes", supply: "100000", features: ["governance", "snapshot"] }, { name: "Rewards Token", symbol: "RWD", type: "ERC20", supply: "5000000", features: ["mintable", "capped"] } ] // Deploy all tokens in a single transaction const results = await multiFactory.deployBatch(tokenSuite, { gasOptimization: true, sharedOwner: omne.getAddress(), verifyContracts: true }) console.log('Token suite deployed:') results.forEach((result, index) => { console.log(`${tokenSuite[index].name}: ${result.contractAddress}`) }) return results }

Token Management

Minting and Burning

Manage token supply with controlled minting and burning operations.

import { OmneSDK, Token } from '@omne/sdk' async function manageTokenSupply(tokenAddress: string) { const omne = new OmneSDK({ network: 'mainnet', privateKey: process.env.PRIVATE_KEY }) const token = new Token(omne, tokenAddress) // Check current supply const totalSupply = await token.totalSupply() const maxSupply = await token.maxSupply() console.log(`Current supply: ${totalSupply}`) console.log(`Max supply: ${maxSupply}`) // Mint new tokens (only if you're the owner/minter) const mintAmount = "10000" // 10,000 tokens const recipient = "0x742d35Cc6474C19B73c7BCd8F47C4289b4b0A58e" const mintResult = await token.mint(recipient, mintAmount) console.log('Minted tokens:', mintResult.transactionHash) // Burn tokens from your own balance const burnAmount = "5000" // 5,000 tokens const burnResult = await token.burn(burnAmount) console.log('Burned tokens:', burnResult.transactionHash) // Check updated supply const newTotalSupply = await token.totalSupply() console.log(`New total supply: ${newTotalSupply}`) return { mintTransaction: mintResult, burnTransaction: burnResult, newSupply: newTotalSupply } }

Access Control & Permissions

Implement role-based access control for token operations and administrative functions.

import { OmneSDK, AccessControlToken } from '@omne/sdk' async function setupTokenPermissions(tokenAddress: string) { const omne = new OmneSDK({ network: 'mainnet', privateKey: process.env.PRIVATE_KEY }) const token = new AccessControlToken(omne, tokenAddress) // Define roles const MINTER_ROLE = await token.MINTER_ROLE() const BURNER_ROLE = await token.BURNER_ROLE() const PAUSER_ROLE = await token.PAUSER_ROLE() // Grant minter role to a specific address const minterAddress = "0x123..." await token.grantRole(MINTER_ROLE, minterAddress) console.log(`Granted MINTER_ROLE to ${minterAddress}`) // Grant multiple roles to treasury const treasuryAddress = "0x456..." await token.grantRole(MINTER_ROLE, treasuryAddress) await token.grantRole(BURNER_ROLE, treasuryAddress) console.log('Treasury permissions configured') // Check if address has role const hasMinterRole = await token.hasRole(MINTER_ROLE, minterAddress) console.log(`Address has minter role: ${hasMinterRole}`) // Revoke role await token.revokeRole(MINTER_ROLE, minterAddress) console.log('Minter role revoked') // Get all accounts with a specific role const allMinters = await token.getRoleMembers(MINTER_ROLE) console.log('All minters:', allMinters) return { roles: { minter: MINTER_ROLE, burner: BURNER_ROLE, pauser: PAUSER_ROLE }, members: allMinters } }

Token Analytics & Monitoring

Real-time Token Metrics

Monitor token performance, holder distribution, and transaction patterns.

import { OmneSDK, TokenAnalytics } from '@omne/sdk' async function getTokenMetrics(tokenAddress: string) { const omne = new OmneSDK({ network: 'mainnet', apiKey: process.env.OMNE_API_KEY }) const analytics = new TokenAnalytics(omne, tokenAddress) // Basic token information const tokenInfo = await analytics.getTokenInfo() console.log('Token Info:', { name: tokenInfo.name, symbol: tokenInfo.symbol, totalSupply: tokenInfo.totalSupply, holders: tokenInfo.holderCount, marketCap: tokenInfo.marketCap }) // Holder distribution const distribution = await analytics.getHolderDistribution({ limit: 100, includeContracts: false }) console.log('Top 10 Holders:') distribution.slice(0, 10).forEach((holder, index) => { console.log(`${index + 1}. ${holder.address}: ${holder.balance} (${holder.percentage}%)`) }) // Transaction history const transfers = await analytics.getTransfers({ fromBlock: 'latest-1000', toBlock: 'latest', limit: 50 }) console.log(`Recent transfers: ${transfers.length}`) // Price and volume data (if available) const priceData = await analytics.getPriceData('24h') console.log('24h Price Data:', { currentPrice: priceData.currentPrice, priceChange24h: priceData.priceChange24h, volume24h: priceData.volume24h, marketCap: priceData.marketCap }) // Generate analytics report const report = await analytics.generateReport({ period: '7d', includeHolders: true, includeTransfers: true, includePriceData: true }) console.log('Weekly Analytics Report Generated') return report }

Best Practices

🔒 Security Considerations

  • • Always use role-based access control for administrative functions
  • • Implement proper pause mechanisms for emergency situations
  • • Use time-locks for critical operations like supply changes
  • • Audit smart contracts before mainnet deployment
  • • Consider implementing upgrade patterns for future improvements

📊 Tokenomics Design

  • • Define clear utility and value accrual mechanisms
  • • Implement sustainable emission schedules
  • • Consider deflationary mechanisms like burning
  • • Plan for governance token distribution
  • • Design incentive alignment between stakeholders

🚀 Deployment Strategy

  • • Test thoroughly on testnet before mainnet deployment
  • • Prepare comprehensive documentation and guides
  • • Plan initial distribution and liquidity provision
  • • Implement monitoring and analytics from day one
  • • Establish clear governance processes early

Related Examples