# /deploy-full - Full Deployment to Movement Network

**Agent:** `devops`

Deploy the complete dApp to Movement testnet or mainnet.

**IMPORTANT**: Delegate to `devops` agent.

## Prerequisites

1. **Movement CLI installed** - See [Movement CLI docs](https://docs.movementnetwork.xyz/devs/movementcli)
2. **Wallet configured** in `.movement/config.yaml`
3. **Sufficient tokens** from [faucet](https://faucet.movementnetwork.xyz/) (for testnet)

## Workflow

### Step 1: Pre-Deployment Checks

1. **Verify all tests pass**
   ```bash
   cd contracts && movement move test
   cd ../frontend && npm test
   ```

2. **Run security review**
   Execute `/review` command and ensure no critical issues

3. **Verify Movement CLI configuration**
   Check `.movement/config.yaml` is configured for the target network:
   ```yaml
   ---
   profiles:
     default:
       network: Custom
       private_key: "0xYOUR_PRIVATE_KEY"
       public_key: "0xYOUR_PUBLIC_KEY"
       account: "YOUR_ACCOUNT_ADDRESS"
       rest_url: "https://full.testnet.movementinfra.xyz/v1"  # or mainnet
       faucet_url: "https://faucet.testnet.movementnetwork.xyz/"
   ```

4. **Configure Move.toml addresses**
   Add your deployment address to `contracts/Move.toml`:
   ```toml
   [addresses]
   module_addr = "YOUR_ACCOUNT_ADDRESS"
   ```

### Step 2: Deploy Smart Contracts

Use `/deploy-smart-contract` command or run manually:

#### Testnet Deployment
```bash
cd contracts
movement move publish --named-addresses module_addr=default
```

#### Mainnet Deployment
```bash
cd contracts
movement move publish \
  --url https://full.mainnet.movementinfra.xyz/v1 \
  --named-addresses module_addr=default
```

When prompted:
```
Do you want to submit this transaction? [Y/n]
```
Type `Y` and press **Enter** to confirm.

> **Important:** Ensure you have sufficient tokens from the faucet before proceeding.

### Step 3: Verify Contract Deployment

1. Get deployed address and transaction hash from output
2. Verify on Movement Explorer:
   - Testnet: `https://explorer.movementnetwork.xyz/?network=testnet`
   - Mainnet: `https://explorer.movementnetwork.xyz/?network=mainnet`

### Step 4: Update Frontend Configuration

Update contract address in `frontend/.env` so the frontend can interact with the deployed contract:

```bash
# frontend/.env
VITE_MODULE_ADDRESS=<YOUR_DEPLOYED_CONTRACT_ADDRESS>
VITE_NETWORK=testnet  # or mainnet
VITE_NODE_URL=https://full.testnet.movementinfra.xyz/v1  # or mainnet URL
```

### Step 5: Deploy Frontend

```bash
cd frontend
npm run build
# Deploy to hosting service (Vercel, Netlify, etc.)
```

### Step 6: Post-Deployment Verification

1. Test contract interactions via Explorer
2. Test frontend wallet connection
3. Execute sample transactions

## Sub-Commands

### /deploy-full:testnet
Deploy complete dApp to testnet

### /deploy-full:mainnet
Deploy complete dApp to mainnet (requires additional confirmation)

### /deploy-full:contracts
Deploy only smart contracts (see `/deploy-smart-contract`)

## Deployment Report

```markdown
# 🚀 Deployment Complete!

## Network: {Testnet/Mainnet}
## Timestamp: {ISO timestamp}

## Smart Contracts
| Module | Address | Tx Hash |
|--------|---------|---------|
| module_name | 0x... | 0x... |

## Verification Links
- Explorer: {link}
- Contract: {link}

## Configuration Updates
- Frontend config updated: ✅

## Post-Deployment Tests
- Contract interaction: ✅
- Frontend connection: ✅

## Next Steps
1. Monitor contract activity on Explorer
2. Set up alerts for critical events
3. Document deployment for team
```

## Safety Checks

### Mainnet Deployment Requires:
- [ ] All tests passing
- [ ] Security review completed with no critical issues
- [ ] Testnet deployment successful
- [ ] Manual confirmation from user
- [ ] Backup of deployment keys

## Success Criteria
- Deployment completed in <5 minutes
- All contracts verified on Explorer
- Configuration files updated
- Post-deployment tests passing

