$npx -y skills add aptos-labs/aptos-agent-skills --skill deploy-contractsSafely deploys Move contracts to Aptos networks (devnet, testnet, mainnet) with pre-deployment verification. Triggers on: 'deploy contract', 'publish to testnet', 'deploy to mainnet', 'how to deploy', 'publish module', 'deployment checklist', 'deploy to devnet'.
| 1 | # Deploy Contracts Skill |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | This skill guides safe deployment of Move contracts to Aptos networks. **Always deploy to testnet before mainnet.** |
| 6 | |
| 7 | ## Pre-Deployment Checklist |
| 8 | |
| 9 | Before deploying, verify ALL items: |
| 10 | |
| 11 | ### Security Audit ⭐ CRITICAL - See [SECURITY.md](../../../patterns/move/SECURITY.md) |
| 12 | |
| 13 | - [ ] Security audit completed (use `security-audit` skill) |
| 14 | - [ ] All critical vulnerabilities fixed |
| 15 | - [ ] All security patterns verified (arithmetic safety, storage scoping, reference safety, business logic) |
| 16 | - [ ] Access control verified (signer checks, object ownership) |
| 17 | - [ ] Input validation implemented (minimum thresholds, fee validation) |
| 18 | - [ ] No unbounded iterations (per-user storage, not global vectors) |
| 19 | - [ ] Atomic operations (no front-running opportunities) |
| 20 | - [ ] Randomness security (if applicable - entry functions, gas balanced) |
| 21 | |
| 22 | ### Testing |
| 23 | |
| 24 | - [ ] 100% test coverage achieved: `aptos move test --coverage` |
| 25 | - [ ] All tests passing: `aptos move test` |
| 26 | - [ ] Coverage report shows 100.0% |
| 27 | - [ ] Edge cases tested |
| 28 | |
| 29 | ### Code Quality |
| 30 | |
| 31 | - [ ] Code compiles without errors: `aptos move compile` |
| 32 | - [ ] No hardcoded addresses (use named addresses) |
| 33 | - [ ] Error codes clearly defined |
| 34 | - [ ] Functions properly documented |
| 35 | |
| 36 | ### Configuration |
| 37 | |
| 38 | - [ ] Move.toml configured correctly |
| 39 | - [ ] Named addresses set up: `my_addr = "_"` |
| 40 | - [ ] Dependencies specified with correct versions |
| 41 | - [ ] Network URLs configured |
| 42 | |
| 43 | ## Object Deployment (Modern Pattern) |
| 44 | |
| 45 | ### CRITICAL: Use Correct Deployment Command |
| 46 | |
| 47 | There are TWO ways to deploy contracts. For modern object-based contracts, use `deploy-object`: |
| 48 | |
| 49 | **✅ CORRECT: Object Deployment (Modern Pattern)** |
| 50 | |
| 51 | ```bash |
| 52 | aptos move deploy-object \ |
| 53 | --address-name my_addr \ |
| 54 | --profile devnet \ |
| 55 | --assume-yes |
| 56 | ``` |
| 57 | |
| 58 | **What this does:** |
| 59 | |
| 60 | 1. Creates an object to host your contract code |
| 61 | 2. Deploys the package to that object's address |
| 62 | 3. Returns the object address (deterministic, based on deployer + package name) |
| 63 | 4. Object address becomes your contract address |
| 64 | |
| 65 | **❌ WRONG: Using Regular Publish for Object Contracts** |
| 66 | |
| 67 | ```bash |
| 68 | # ❌ Don't use this for object-based contracts |
| 69 | aptos move publish \ |
| 70 | --named-addresses my_addr=<address> |
| 71 | ``` |
| 72 | |
| 73 | **When to use each:** |
| 74 | |
| 75 | - `deploy-object`: Modern contracts using objects (RECOMMENDED) |
| 76 | - `publish`: Legacy account-based deployment (older pattern) |
| 77 | |
| 78 | **How to tell if you need object deployment:** |
| 79 | |
| 80 | - Your contract creates named objects in `init_module` |
| 81 | - Your contract uses `object::create_named_object()` |
| 82 | - You want a deterministic contract address |
| 83 | - Documentation says "deploy as object" |
| 84 | |
| 85 | ### Alternative Object Deployment Commands |
| 86 | |
| 87 | **Option 1: `deploy-object` (Recommended - Simplest)** |
| 88 | |
| 89 | ```bash |
| 90 | aptos move deploy-object --address-name my_addr --profile devnet |
| 91 | ``` |
| 92 | |
| 93 | - Automatically creates object and deploys code |
| 94 | - Object address is deterministic |
| 95 | - Best for most use cases |
| 96 | |
| 97 | **Option 2: `create-object-and-publish-package` (Advanced)** |
| 98 | |
| 99 | ```bash |
| 100 | aptos move create-object-and-publish-package \ |
| 101 | --address-name my_addr \ |
| 102 | --named-addresses my_addr=default |
| 103 | ``` |
| 104 | |
| 105 | - More complex command with more options |
| 106 | - Use only if you need specific object configuration |
| 107 | - Generally not needed |
| 108 | |
| 109 | **Recommendation:** Always use `deploy-object` unless you have a specific reason to use the alternative. |
| 110 | |
| 111 | ## Deployment Workflow |
| 112 | |
| 113 | ### Step 1: Test Locally |
| 114 | |
| 115 | ```bash |
| 116 | # Ensure all tests pass |
| 117 | aptos move test |
| 118 | |
| 119 | # Verify 100% coverage |
| 120 | aptos move test --coverage |
| 121 | aptos move coverage summary |
| 122 | # Expected output: "coverage: 100.0%" |
| 123 | ``` |
| 124 | |
| 125 | ### Step 2: Compile |
| 126 | |
| 127 | ```bash |
| 128 | # Compile contract |
| 129 | aptos move compile --named-addresses my_addr=<your_address> |
| 130 | |
| 131 | # Verify compilation succeeds |
| 132 | echo $? |
| 133 | # Expected: 0 (success) |
| 134 | ``` |
| 135 | |
| 136 | ### Step 3: Deploy to Devnet (Optional) |
| 137 | |
| 138 | **Devnet is for quick testing and experimentation. Account is auto-funded on `aptos init`.** |
| 139 | |
| 140 | Check if a profile exists before initializing: |
| 141 | |
| 142 | ```bash |
| 143 | # Check if default profile exists (look for "default" in output) |
| 144 | aptos config show-profiles |
| 145 | |
| 146 | # If no profile exists, initialize one (auto-funds on devnet) |
| 147 | aptos init --network devnet --assume-yes |
| 148 | ``` |
| 149 | |
| 150 | ```bash |
| 151 | # Deploy as object (modern pattern) |
| 152 | aptos move deploy-object \ |
| 153 | --address-name my_addr \ |
| 154 | --profile default \ |
| 155 | --assume-yes |
| 156 | |
| 157 | # Save the object address from output for future upgrades |
| 158 | # Output: "Code was successfully deployed to object address 0x..." |
| 159 | |
| 160 | # Verify deployment |
| 161 | aptos account list --account <object_address> --profile default |
| 162 | ``` |
| 163 | |
| 164 | ### Step 4: Deploy to Testnet (REQUIRED) |
| 165 | |
| 166 | **Testnet is for final testing before mainnet.** |
| 167 | |
| 168 | Check if a p |