export SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/YOUR_KEY"
export SEPOLIA_PRIVATE_KEY="your_private_key_here"
export TEN_PRIVATE_KEY="your_private_key_here"cd contracts_tenchat
npx hardhat compileOption A: Using Ignition (Recommended)
# Deploy to Sepolia
npx hardhat ignition deploy ignition/modules/TenChatDeploy.ts --network sepolia
# Deploy to Ten Network
npx hardhat ignition deploy ignition/modules/TenChatDeploy.ts --network ten
# Deploy to local hardhat
npx hardhat ignition deploy ignition/modules/TenChatDeploy.ts --network hardhatMainnetOption B: Using Custom Script
# Deploy to Sepolia
npx hardhat run scripts/deploy.ts --network sepolia
# Deploy to Ten Network
npx hardhat run scripts/deploy.ts --network ten
# Deploy locally
npx hardhat run scripts/deploy.ts --network hardhat- Purpose: Central registry, user profiles, username management
- Features:
- Register users with unique usernames
- Update usernames
- Check username availability
- Contract registry for other contracts
- Purpose: End-to-end encrypted messaging
- Features:
- Send encrypted messages
- Message history
- User-to-user communication
- Purpose: Crypto gifting system
- Features:
- Send ETH/tokens as gifts
- Gift history
- Event tracking
- Purpose: Subscription management
- Features:
- Create subscription plans
- Subscribe to users
- Manage subscriptions
# Run all tests
npx hardhat test
# Run specific test
npx hardhat test test/Core.test.ts
npx hardhat test test/Gifting.test.ts
npx hardhat test test/EncryptedChat.test.tsAfter deployment, verify on Etherscan:
# Set contract addresses
export CORE_ADDRESS="0x..."
export ENCRYPTED_CHAT_ADDRESS="0x..."
export GIFTING_ADDRESS="0x..."
export SUBSCRIPTION_ADDRESS="0x..."
# Run verification script
npx hardhat run scripts/verify.ts --network sepolia- RPC: Configure in
SEPOLIA_RPC_URL - Chain ID: 11155111
- Explorer: https://sepolia.etherscan.io
- RPC: https://testnet.ten.xyz/v1/
- Chain ID: 443
- Explorer: https://testnet.tenscan.io
# Compile
npx hardhat compile
# Clean
npx hardhat clean
# Test
npx hardhat test
# Deploy (Sepolia)
npx hardhat ignition deploy ignition/modules/TenChatDeploy.ts --network sepolia
# Deploy (Ten)
npx hardhat ignition deploy ignition/modules/TenChatDeploy.ts --network ten
# Node
npx hardhat node
# Console
npx hardhat console --network sepolia- Environment variables set
- Wallet has sufficient funds (gas)
- Contracts compiled successfully
- Tests passing
- Deploy to testnet
- Verify deployment
- Save contract addresses
- Update frontend with addresses
- Test on frontend
Create a .env file or export:
# Sepolia
export SEPOLIA_RPC_URL="https://sepolia.infura.io/v3/YOUR_INFURA_KEY"
export SEPOLIA_PRIVATE_KEY="0xYOUR_PRIVATE_KEY"
# Ten Network
export TEN_PRIVATE_KEY="0xYOUR_PRIVATE_KEY"
# Optional: For verification
export ETHERSCAN_API_KEY="YOUR_ETHERSCAN_KEY"After successful deployment, you'll get:
🎉 Deployment Complete!
Contract Addresses:
===================
Core: 0x742d35Cc6634C0532925a3b844C2468bB3Ff16B2
EncryptedChat: 0x8B5e5f5e5e5e5e5e5e5e5e5e5e5e5e5e5e5e5e5e
Gifting: 0x9C6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f
Subscription: 0x1D7g7g7g7g7g7g7g7g7g7g7g7g7g7g7g7g7g7g7g
💡 Save these addresses for frontend integration!
- Ensure wallet has testnet ETH
- Get testnet ETH from faucet
- Reset Hardhat network:
npx hardhat clean
- Run
npx hardhat compilefirst
- Check hardhat.config.ts network names
Once tested on testnet:
- Update network config for mainnet
- Ensure sufficient mainnet ETH
- Deploy using same commands
- Verify contracts on Etherscan
- Update frontend with mainnet addresses
- Hardhat: https://hardhat.org/docs
- Ignition: https://hardhat.org/ignition/docs
- OpenZeppelin: https://docs.openzeppelin.com/contracts