This guide covers the deployment process for PropChain smart contracts across different networks and environments.
- Rust and cargo-contract installed
- Substrate node (for local deployment)
- Account with sufficient funds (for testnet/mainnet deployment)
- Network-specific configuration
# Build in debug mode
cargo contract build
# Build with verbose output
cargo contract build --verbose# Build optimized contract
cargo contract build --release
# Verify build artifacts
ls -la target/ink/# Start a local Substrate node
substrate-node-template --dev --tmp
# Or use a pre-configured node
./scripts/start-local-node.sh# Instantiate contract
cargo contract instantiate \
--constructor new \
--args "" \
--suri //Alice \
--salt $(date +%s)
# Get contract address
cargo contract info# Set environment variables
export NETWORK=westend
export NODE_URL=wss://westend-rpc.polkadot.io
export SURI=your mnemonic phraseexport NETWORK=rococo
export NODE_URL=wss://rococo-rpc.polkadot.io# 1. Build contract
cargo contract build --release
# 2. Upload contract code
cargo contract upload \
--url $NODE_URL \
--suri $SURI
# 3. Instantiate contract
cargo contract instantiate \
--constructor new \
--args "" \
--url $NODE_URL \
--suri $SURI \
--salt $(date +%s)- Contract audited by security firm
- All tests passing
- Gas optimization completed
- Documentation updated
- Emergency procedures documented
- Funding allocated for deployment costs
# 1. Final build verification
cargo contract build --release
cargo test --release
# 2. Upload to mainnet
cargo contract upload \
--url wss://rpc.polkadot.io \
--suri "$MAINNET_SURI" \
--confirm
# 3. Instantiate with verification
cargo contract instantiate \
--constructor new \
--args "" \
--url wss://rpc.polkadot.io \
--suri "$MAINNET_SURI" \
--confirm \
--salt $(date +%s)- Gas Costs: Higher than testnets
- Finality: ~24 seconds
- Security: Relay chain security
- Upgradeability: Proxy pattern recommended
- Gas Costs: Lower than Polkadot
- Finality: ~12 seconds
- Experimental: Faster feature rollout
- Risk: Higher network risk
- Configuration: Varies by parachain
- Gas Model: May differ from relay chain
- Security: Depends on parachain
- Integration: May require custom adapters
# Verify contract code matches source
cargo contract verify \
--contract $CONTRACT_ADDRESS \
--url $NODE_URL# Generate build info
cargo contract build --release --output-json > build-info.json
# Compare with deployed version
./scripts/verify-deployment.sh $CONTRACT_ADDRESS build-info.json# Monitor contract events
./scripts/monitor-contract.sh $CONTRACT_ADDRESS
# Check contract health
./scripts/health-check.sh $CONTRACT_ADDRESS# 1. Deploy new version
cargo contract upload --new-version
# 2. Migrate to new contract
./scripts/migrate-contract.sh $OLD_ADDRESS $NEW_ADDRESS
# 3. Verify migration
./scripts/verify-migration.sh $NEW_ADDRESS# Check account balance
./scripts/check-balance.sh $ACCOUNT_ADDRESS
# Transfer funds if needed
./scripts/transfer-funds.sh $ACCOUNT_ADDRESS $AMOUNT# Estimate gas usage
cargo contract estimate-gas \
--contract $CONTRACT_ADDRESS \
--method $METHOD_NAME \
--args "$ARGS"
# Increase gas limit
cargo contract call \
--contract $CONTRACT_ADDRESS \
--method $METHOD_NAME \
--args "$ARGS" \
--gas-limit 1000000000000# Check transaction status
./scripts/check-tx.sh $TRANSACTION_HASH
# Debug with verbose output
cargo contract call \
--contract $CONTRACT_ADDRESS \
--method $METHOD_NAME \
--args "$ARGS" \
--verbose# Use secure key storage
export SURI=$(pass show polkadot/mainnet/deployer)
# Never log sensitive data
set +x # Disable command logging
cargo contract instantiate --suri "$SURI"
set -x# Deploy with multi-sig
./scripts/deploy-multisig.sh \
--contract $CONTRACT_ADDRESS \
--threshold 2 \
--signers $SIGNER1 $SIGNER2 $SIGNER3# Emergency pause
./scripts/emergency-pause.sh $CONTRACT_ADDRESS
# Emergency upgrade
./scripts/emergency-upgrade.sh $CONTRACT_ADDRESS $NEW_CODE_HASHPropChain uses GitHub Actions for automated deployments. The pipeline is defined in .github/workflows/deploy.yml.
- Pre-deployment Tests - Formatting, linting, and unit tests must pass.
- Security Checks -
cargo auditscans for known vulnerabilities. - Build - Release artifacts are compiled and stored.
- Deploy - Contracts are deployed to the target network.
- Rollback - Automatic rollback if deployment fails.
- Notification - Reports deployment status.
Deployments are triggered automatically on version tags or manually via workflow dispatch.
# Tag-based deployment (triggers automatically)
git tag v1.0.0
git push origin v1.0.0
# Manual deployment via GitHub CLI
gh workflow run deploy.yml \
--field network=westend \
--field dry_run=falseThe scripts/deploy.sh script supports several commands.
# Deploy all contracts to a network
./scripts/deploy.sh --network westend
# Deploy a specific contract with verification
./scripts/deploy.sh --network westend --contract property-token --verify
# List current deployments
./scripts/deploy.sh --network westend --list
# Rollback to previous deployment state
./scripts/deploy.sh --network westend --rollback
# Skip pre-deployment tests (not recommended for production)
./scripts/deploy.sh --network local --skip-testsThe deployment script backs up the current deployment state before deploying. If deployment fails, it automatically restores the previous state.
Note: On-chain contracts are immutable. Rollback restores local deployment records (addresses, code hashes). If a deployed contract is faulty, redeploy the previous version as a new instance.
# Rollback to the most recent backup
./scripts/deploy.sh --network westend --rollback
# Rollback to a specific backup
./scripts/deploy.sh --network westend --rollback deployments/backups/westend-20240101-120000Backups are stored in deployments/backups/ with timestamped directories.
deployments/
backups/
westend-20240101-120000/
property-token.json
property-registry.json
westend-20240115-090000/
property-token.json
westend/
property-token.json
property-registry.json
- Update contract addresses in documentation
- Add deployment notes to changelog
- Update API documentation if needed
- Notify stakeholders of deployment
- Announce deployment on Discord/Telegram
- Post deployment summary on GitHub
- Update project status page
- Send notification to subscribers
The deploy script includes a built-in monitoring step that verifies contract accessibility and reports the on-chain code hash after each deployment.
For ongoing monitoring:
- Verify contract accessibility using
cargo contract info --contract $ADDRESS --url $NODE_URL - Track gas usage patterns by reviewing transaction history on block explorers
- Monitor contract events using Substrate event subscriptions
- Set up alerts for failed transactions or unexpected state changes