Skip to main content

Testnet Deployment 🌐

This guide covers deploying DolphinPay smart contracts to the Sui testnet for testing and development.

Prerequisites

Before deploying to testnet, ensure you have:

  • Sui CLI installed and configured
  • Testnet environment active (sui client switch --env testnet)
  • Testnet SUI tokens in your wallet
  • Smart contracts built successfully (sui move build)

Step 1: Environment Setup

Switch to Testnet

# Check current environment
sui client active-env

# Switch to testnet
sui client switch --env testnet

# Verify switch
sui client active-env # Should show "testnet"

Check Your Balance

# Check SUI balance
sui client balance

# Check gas objects
sui client gas

# If insufficient balance, get testnet tokens
echo "Get tokens from: https://docs.sui.io/guides/developer/getting-started/get-coins"

Step 2: Build Contracts

Build for Testnet

# Navigate to contract directory
cd contract

# Build contracts
sui move build

# Verify build succeeded
ls -la build/

Check Build Output

The build should create:

build/
├── DolphinPay/
│ ├── bytecode/
│ │ ├── modules/
│ │ │ ├── payment.mv
│ │ │ ├── merchant.mv
│ │ │ └── events.mv
│ │ └── scripts/
│ ├── source_maps/
│ └── types/
└── genesis.blob

Step 3: Deploy to Testnet

Execute Deployment

# Deploy with sufficient gas budget
sui client publish --gas-budget 100000000

Expected Output:

----- Certificate ----
Transaction Hash: [transaction_hash]
Transaction Signature: [signature] => [address]
Signed Authorities Bitmap: [bitmap]
Transaction Kind: Publish
Sender: [your_address]
Gas Payment: [gas_object_id]
Gas Owner: [your_address]
Gas Price: 1000
Gas Budget: 100000000

----- Transaction Effects ----
Status: Success
Created Objects:
- Object ID: [package_id]
Type: Move Package
Owner: Immutable
- Object ID: [admin_config_id]
Type: [package_id]::admin::AdminConfig
Owner: [your_address]

Save Important Information

⚠️ Important: Save these values for your configuration:

# Package ID - Main contract address
PACKAGE_ID="0x9c7ca262d020b005e0e6b6a5d083b329d58716e0d80c07b46804324074468f9c"

# AdminConfig ID - Admin configuration object
ADMIN_CONFIG_ID="0x[admin_config_object_id]"

# Transaction Hash - For verification
TX_HASH="[transaction_hash]"

Step 4: Verify Deployment

Check Package Information

# View package details
sui client object $PACKAGE_ID

# View AdminConfig
sui client object $ADMIN_CONFIG_ID

# Check transaction on explorer
echo "https://testnet.suivision.xyz/tx/$TX_HASH"

Verify Contract Modules

# List all objects created in deployment
sui client objects --json | jq '.[] | select(.data.type | contains("'$PACKAGE_ID'"))'

# Expected modules:
# - payment
# - merchant
# - events
# - admin

Step 5: Test Deployment

Create Test Merchant

# Register a test merchant
sui client call \
--package $PACKAGE_ID \
--module merchant \
--function register_merchant \
--args "Test Merchant" "Test Description" \
--gas-budget 10000000

Create Test Payment

# Create a test payment (replace with actual merchant address)
sui client call \
--package $PACKAGE_ID \
--module payment \
--function create_payment \
--args "0x[merchant_address]" "1000000000" "0x2::sui::SUI" "Test Payment" "[]" "3600" \
--gas-budget 10000000

Step 6: Configure for Development

Update SDK Configuration

Create/update sdk/.env:

# Network settings
SUI_NETWORK=testnet
PACKAGE_ID=0x9c7ca262d020b005e0e6b6a5d083b329d58716e0d80c07b46804324074468f9c

# RPC endpoints
TESTNET_RPC=https://fullnode.testnet.sui.io:443

Update Frontend Configuration

Create/update frontend/.env.local:

# Network configuration
NEXT_PUBLIC_SUI_NETWORK=testnet
NEXT_PUBLIC_PACKAGE_ID=0x9c7ca262d020b005e0e6b6a5d083b329d58716e0d80c07b46804324074468f9c

# Admin configuration (optional)
NEXT_PUBLIC_ADMIN_CONFIG_ID=0x[admin_config_id]

Step 7: Run Integration Tests

Test SDK Integration

cd sdk

# Install dependencies
npm install

# Build SDK
npm run build

# Run integration tests
npm run test:integration

Test Frontend Integration

cd frontend

# Install dependencies
npm install

# Run development server
npm run dev

# Test payment creation
# Test merchant registration
# Test wallet integration

Troubleshooting

Deployment Issues

"Insufficient gas"

# Increase gas budget
sui client publish --gas-budget 200000000

# Or split gas objects
sui client split-coin --coin-id [gas_object_id] --amounts 50000000 50000000

"Package already exists"

# This is normal - the package is immutable on-chain
# Use the existing package ID for your integration

"AdminConfig not found"

# Find AdminConfig object
sui client objects --json | jq '.[] | select(.data.type | contains("AdminConfig"))'

# Or check transaction on explorer
sui client tx $TX_HASH

Network Issues

"Connection refused"

# Check network connectivity
curl -X POST https://fullnode.testnet.sui.io:443 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"sui_getChainIdentifier","params":[]}'

# Switch to different RPC if needed
sui client switch --env testnet

"Transaction timeout"

# Increase gas price for faster processing
sui client publish --gas-budget 100000000 --gas-price 2000

# Or check network status
sui client chain-identifier

Security Considerations

Testnet vs Mainnet

  • Testnet: Safe for testing, tokens have no real value
  • Mainnet: Real tokens, real value - use with caution

Best Practices

  1. Start with small amounts for testing
  2. Use separate wallet for testnet and mainnet
  3. Save all deployment information securely
  4. Test all functionality before going live
  5. Monitor gas usage and optimize where possible

Monitoring and Analytics

Track Deployment

# Monitor your objects
sui client objects --owner [your_address]

# Track transaction history
sui client tx-history [your_address]

# Monitor gas usage
sui client gas [your_address]

Explorer Integration

Next Steps

After Successful Deployment

  1. SDK Integration - Start building with the SDK
  2. Payment Operations - Learn to handle payments
  3. Merchant Operations - Manage merchant functionality
  4. Basic Payment Example - See a complete integration

Advanced Testing

  1. Integration Testing - Test full payment flows
  2. Stress Testing - Test with multiple concurrent users
  3. Gas Optimization - Analyze and optimize gas usage
  4. Security Testing - Test edge cases and error conditions

Get Help


Congratulations! 🎉 Your DolphinPay contracts are now live on Sui testnet. Ready to start building your payment integration?