---
name: deploy-contract
description: Compile, test, and deploy the MicroCredentialSBT smart contract to Polygon Amoy or local network
---
# Deploy Smart Contract

Deploy the MicroCredentialSBT contract. Target network from $ARGUMENTS (default: amoy).

1. `cd blockchain`
2. Run `npx hardhat compile` — fix any Solidity errors
3. Run `npx hardhat test` — ensure all tests pass before deploying
4. Check that `blockchain/.env` has PRIVATE_KEY, POLYGON_AMOY_RPC_URL, and POLYGONSCAN_API_KEY set
5. Deploy: `npx hardhat run scripts/deploy.js --network <target>`
6. Copy the deployed contract address and update:
   - `blockchain/.env` → DEPLOYED_CONTRACT_ADDRESS
   - `web/.env` → NEXT_PUBLIC_CONTRACT_ADDRESS
7. Copy the ABI: `cp blockchain/artifacts/contracts/MicroCredentialSBT.sol/MicroCredentialSBT.json ../web/src/constants/contractABI.json`
8. Verify the contract if on amoy: `npx hardhat run scripts/verify.js --network amoy`
9. Report the contract address and Polygonscan URL to the user
