plugins/midnight-tooling/skills/contract-deployment/SKILL.md
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.
npx skillsauth add aaronbassett/midnight-knowledgebase midnight-tooling:contract-deploymentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Deploy Compact smart contracts to Midnight testnet or mainnet with proper configuration, verification, and error handling.
compact compile to generate artifacts| Network | Indexer | Prover | Use Case |
|---------|---------|--------|----------|
| Testnet | indexer.testnet.midnight.network | prover.testnet.midnight.network | Development, testing |
| Mainnet | indexer.midnight.network | prover.midnight.network | Production |
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| Document | Description | |----------|-------------| | deployment-config.md | Network configuration and environment setup | | network-endpoints.md | Endpoint URLs and connection patterns |
| Example | Description | |---------|-------------| | single-contract/ | Deploy a single contract | | multi-contract/ | Deploy multiple contracts with dependencies |
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',
};
import { Contract } from './contract.cjs';
import type { ContractTypes } from './contract.d.cts';
const contractArtifact = Contract;
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);
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',
};
};
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');
}
async function verifyDeployment(
address: string,
indexer: IndexerClient
): Promise<boolean> {
try {
const contractInfo = await indexer.getContractInfo(address);
return contractInfo !== null;
} catch {
return false;
}
}
midnight-setup - Environment prerequisites before deploymentcontract-calling - Invoking deployed contractslifecycle-management - Managing contracts post-deploymentmidnight-ci - Automated deployment in CI/CD/midnight:check - Verify environment is ready for deploymenttools
Use when setting up Midnight development environment, installing Compact compiler and developer tools, configuring proof server, verifying prerequisites, or getting started with Midnight development.
tools
--- name: midnight-tooling:midnight-debugging description: Use when encountering Midnight errors like "compact: command not found", "ERR_UNSUPPORTED_DIR_IMPORT", version mismatches, proof server failures, "@midnight-ntwrk" package errors, or compilation failures. --- # Midnight Environment Debugging Expert knowledge for identifying and resolving common Midnight development toolchain issues. ## Diagnostic Approach When encountering Midnight-related errors, follow this systematic approach: 1.
tools
Use when checking Midnight version compatibility, understanding pragma language_version, verifying compiler and runtime version relationships, or troubleshooting version mismatch errors between Midnight components.
tools
Use when setting up CI/CD for Midnight projects, configuring GitHub Actions for Compact contract compilation, running TypeScript tests in CI, validating version consistency, or automating contract builds.