Agent skill
midnight-tooling:contract-deployment
Use when deploying Compact contracts to Midnight testnet or mainnet, configuring network endpoints, handling deployment confirmation, troubleshooting failed deployments, or setting up deployment scripts for CI/CD.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/contract-deployment
SKILL.md
Contract Deployment
Deploy Compact smart contracts to Midnight testnet or mainnet with proper configuration, verification, and error handling.
When to Use
- Deploying a compiled Compact contract for the first time
- Configuring network endpoints for deployment
- Handling deployment transaction confirmation
- Troubleshooting failed deployments
- Setting up deployment scripts for CI/CD
Key Concepts
Deployment Flow
- Compile contract - Use
compact compileto generate artifacts - Configure network - Set indexer, prover, and node endpoints
- Fund deployer - Ensure account has sufficient tDUST (testnet) or DUST (mainnet)
- Submit transaction - Deploy contract and wait for confirmation
- Verify deployment - Query contract address on chain
Network Configuration
| Network | Indexer | Prover | Use Case |
|---|---|---|---|
| Testnet | indexer.testnet.midnight.network |
prover.testnet.midnight.network |
Development, testing |
| Mainnet | indexer.midnight.network |
prover.midnight.network |
Production |
Contract Artifacts
After compact compile, the output directory contains:
contract.cjs- Contract bytecode and circuitscontract.d.cts- TypeScript types for contract interfacecircuit-keys/- ZK circuit proving keys
References
| Document | Description |
|---|---|
| deployment-config.md | Network configuration and environment setup |
| network-endpoints.md | Endpoint URLs and connection patterns |
Examples
| Example | Description |
|---|---|
| single-contract/ | Deploy a single contract |
| multi-contract/ | Deploy multiple contracts with dependencies |
Quick Start
1. Configure Network
import { NetworkConfig } from '@midnight-ntwrk/midnight-js-types';
const config: NetworkConfig = {
indexer: 'https://indexer.testnet.midnight.network',
indexerWs: 'wss://indexer.testnet.midnight.network/ws',
prover: 'https://prover.testnet.midnight.network',
};
2. Load Contract Artifacts
import { Contract } from './contract.cjs';
import type { ContractTypes } from './contract.d.cts';
const contractArtifact = Contract;
3. Deploy
import { deployContract } from '@midnight-ntwrk/midnight-js-contracts';
const deployedContract = await deployContract({
wallet,
artifact: contractArtifact,
initialState: { /* initial ledger state */ },
config,
});
console.log('Deployed at:', deployedContract.address);
Common Patterns
Environment-Based Configuration
const getNetworkConfig = (): NetworkConfig => {
const network = process.env.MIDNIGHT_NETWORK || 'testnet';
if (network === 'mainnet') {
return {
indexer: 'https://indexer.midnight.network',
indexerWs: 'wss://indexer.midnight.network/ws',
prover: 'https://prover.midnight.network',
};
}
return {
indexer: 'https://indexer.testnet.midnight.network',
indexerWs: 'wss://indexer.testnet.midnight.network/ws',
prover: 'https://prover.testnet.midnight.network',
};
};
Deployment with Retry
async function deployWithRetry(
config: DeployConfig,
maxRetries = 3
): Promise<DeployedContract> {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
return await deployContract(config);
} catch (error) {
if (attempt === maxRetries) throw error;
console.log(`Attempt ${attempt} failed, retrying...`);
await new Promise(r => setTimeout(r, 2000 * attempt));
}
}
throw new Error('Deployment failed after retries');
}
Deployment Verification
async function verifyDeployment(
address: string,
indexer: IndexerClient
): Promise<boolean> {
try {
const contractInfo = await indexer.getContractInfo(address);
return contractInfo !== null;
} catch {
return false;
}
}
Related Skills
midnight-setup- Environment prerequisites before deploymentcontract-calling- Invoking deployed contractslifecycle-management- Managing contracts post-deploymentmidnight-ci- Automated deployment in CI/CD
Related Commands
/midnight:check- Verify environment is ready for deployment
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?