Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Deploying

This guide covers deploying your magical-nft contracts to various networks.

Deployment Options

magical-nft provides several deployment scripts:

ScriptDescription
DeployFull{{ProjectName}}.s.solDeploy all contracts at once
DeployOnly{{ProjectName}}.s.solDeploy only the main contract
DeployOnly{{ProjectName}}Renderer.s.solDeploy only the renderer
DeployOnly{{ProjectName}}Storage.s.solDeploy only storage

Local Development

Start Anvil

anvil

Deploy All Contracts

forge script script/DeployFull{{ProjectName}}.s.sol \
  --rpc-url http://localhost:8545 \
  --broadcast

Testnet Deployment

Configure Environment

Make sure your .env file has the required values:

SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
PRIVATE_KEY=0x...
ETHERSCAN_API_KEY=...

Deploy to Sepolia

source .env
 
forge script script/DeployFull{{ProjectName}}.s.sol \
  --rpc-url $SEPOLIA_RPC_URL \
  --broadcast \
  --verify

Mainnet Deployment

Pre-flight Checklist

  • All tests passing
  • Contracts verified on testnet
  • Metadata rendering correctly
  • Gas costs estimated
  • Owner addresses confirmed

Deploy to Mainnet

forge script script/DeployFull{{ProjectName}}.s.sol \
  --rpc-url $MAINNET_RPC_URL \
  --broadcast \
  --verify \
  --slow

The --slow flag helps avoid rate limiting during verification.

Post-Deployment

Verify Contracts

If automatic verification failed:

bun run verify

Upload Assets

After deployment, upload your assets:

bun run upload-all-files

Record Addresses

Save your deployed contract addresses in a safe place:

  • Main Contract: 0x...
  • Renderer: 0x...
  • Storage: 0x...

Upgrading Contracts

To upgrade the renderer without affecting existing tokens:

  1. Deploy new renderer: DeployOnly{{ProjectName}}Renderer.s.sol
  2. Call setRenderer(newAddress) on main contract
  3. Verify new metadata is rendering correctly