Complete guide for deploying Certifi to Stacks testnet and mainnet.
- Node.js v16+
- Stacks wallet with STX for gas fees
- Private key from your Stacks wallet
- Stacks address
cp .env.example .envSTACKS_NETWORK=testnet
DEPLOYER_KEY=your_private_key_here
DEPLOYER_ADDRESS=your_stacks_address_hereGetting Your Keys:
- Create a Stacks wallet at Stacks Wallet
- Export your private key (keep it secure!)
- Get your Stacks address (starts with
SPfor testnet,SMfor mainnet)
Testnet:
- Use Stacks Testnet Faucet
- Request STX tokens
Mainnet:
- Purchase STX from exchange
- Transfer to your Stacks address
npm installclarinet checkThis validates contract syntax and catches errors early.
npm run test:runEnsure all tests pass before deployment.
npm run deployThis will:
- Deploy
certifi-institutionscontract - Deploy
certifi-credentialscontract - Save deployment info to
deployments/deployment.json
Check the deployment info:
cat deployments/deployment.jsonYou should see:
- Transaction IDs for both contracts
- Contract addresses
- Deployment timestamp
-
Set network to testnet:
STACKS_NETWORK=testnet
-
Deploy:
npm run deploy
-
Monitor deployment:
- Check Stacks Testnet Explorer
- Search for your transaction ID
- Wait for confirmation (usually 10-30 minutes)
-
Verify contracts:
npm run interact
Get free STX for testing:
# Visit: https://testnet.stacks.co/faucet
# Enter your Stacks address
# Receive 500 STX- Contracts tested thoroughly on testnet
- Security audit completed
- All tests passing
- Deployment plan documented
- Rollback plan prepared
- Sufficient STX for gas fees
-
Update .env for mainnet:
STACKS_NETWORK=mainnet DEPLOYER_KEY=your_private_key DEPLOYER_ADDRESS=your_mainnet_address
-
Final verification:
npm run test:run clarinet check
-
Deploy:
npm run deploy
-
Monitor:
- Check Stacks Mainnet Explorer
- Wait for confirmation
- Verify contract functionality
- Gas Fees: Higher on mainnet, budget accordingly
- Confirmation Time: 10-30 minutes typical
- Irreversible: Mainnet deployments are permanent
- Monitoring: Watch for any issues post-deployment
# Check contract exists
curl https://api.mainnet.stacks.co/v1/contracts/address/CONTRACT_ADDRESS/CONTRACT_NAME
# Call read-only function
npm run interact# Add verifiers
# Register test institutions
# Issue test credentials- Watch transaction confirmations
- Monitor contract calls
- Track gas usage
- Monitor for errors
Update deployment records:
{
"network": "mainnet",
"deployer": "SM...",
"timestamp": "2024-01-01T00:00:00Z",
"contracts": {
"certifi-institutions": {
"txid": "0x...",
"address": "SM....certifi-institutions"
},
"certifi-credentials": {
"txid": "0x...",
"address": "SM....certifi-credentials"
}
}
}Issue: "Insufficient balance"
- Solution: Fund your account with more STX
Issue: "Invalid private key"
- Solution: Check .env file, ensure key is correct
Issue: "Contract already exists"
- Solution: Use different contract name or address
Issue: Transaction pending for hours
- Solution:
- Check network status
- Increase gas price
- Resubmit transaction
Issue: Contract not appearing on explorer
- Solution:
- Wait for confirmation
- Check correct address
- Verify on correct network
| Operation | Estimated STX |
|---|---|
| Deploy contract | 0.1 - 0.5 STX |
| Register institution | 0.01 - 0.05 STX |
| Issue credential | 0.01 - 0.05 STX |
| Verify credential | 0 STX (read-only) |
| Revoke credential | 0.01 - 0.05 STX |
- Batch operations: Combine multiple calls
- Read-only calls: Use for verification (free)
- Off-chain data: Store metadata off-chain
- Contract optimization: Minimize storage operations
- Stop new deployments
- Assess impact
- Communicate with users
- Deploy fix
- Verify fix
- Resume operations
Keep previous versions:
# Archive old contracts
cp contracts/certifi-credentials.clar contracts/certifi-credentials.v1.clar- Transaction success rate
- Average gas usage
- Error rates
- User adoption
- Stacks Explorer
- Stacks API
- Custom monitoring dashboard
Set up alerts for:
- Failed transactions
- High gas usage
- Unusual activity
- Contract errors
- Monitor contract health
- Update verifier list
- Handle disputes
- Security patches
For future upgrades:
- Deploy new contract version
- Migrate data if needed
- Update frontend
- Deprecate old contract
- Archive old data
- Check documentation
- Search GitHub issues
- Ask in community Discord
- File GitHub issue
- Environment configured
- Tests passing
- Contracts verified
- Account funded
- Backup created
- Deploy contracts
- Verify deployment
- Check explorer
- Document addresses
- Initialize system
- Monitor transactions
- Update documentation
- Notify users
- Set up monitoring
- ✅ Deploy to testnet
- ✅ Test thoroughly
- ✅ Get community feedback
- ✅ Security audit
- ✅ Deploy to mainnet
- ✅ Monitor and maintain
Good luck with your deployment! 🚀
- All 6 contracts deployed