Deployment Guide
This guide covers how to deploy the Open Pay smart contracts to BSC Testnet (or Mainnet) and configure them for your environment.Current Testnet Deployment
All contracts are live on BSC Testnet (Chain ID 97):| Contract | Address | Purpose |
|---|---|---|
| OpenPayEscrow | 0xe50464081b781AFE101EB40bC7e68Fd017c5e8f2 | Payment escrow |
| OpenPayPriceFeed | 0x1f34e070D4BB1eD3AaF37D8E3297b0a9A12a3399 | Price oracle aggregator |
| MockUSDT | Testnet ERC-20 | Test USDT token |
| MockUSDC | Testnet ERC-20 | Test USDC token |
| MockPriceFeed | Testnet contract | Simulated Chainlink oracle |
These testnet contracts use mock tokens and mock price feeds. For production, you would use real token addresses and Chainlink oracle feeds.
Deploy Your Own
Prerequisites
- Node.js v18+
- Hardhat or Foundry
- A BSC Testnet wallet with test BNB (get from BNB Faucet)
- A BscScan API key for contract verification
Environment Setup
Deploy Contracts
Deploy to BSC Testnet:The deployment script deploys contracts in this order:
- MockPriceFeed — simulated Chainlink oracle (testnet only)
- MockUSDT — test USDT token (testnet only)
- MockUSDC — test USDC token (testnet only)
- OpenPayPriceFeed — price aggregator
- OpenPayEscrow — payment escrow
- Token price feeds on
OpenPayPriceFeed - Supported tokens on
OpenPayEscrow - Price feed address on
OpenPayEscrow
Adding New Tokens
To support a new ERC-20 token for payments:Configure the Price Feed
Register the token with a Chainlink price feed on the
OpenPayPriceFeed contract:Switching to Mainnet
When deploying to BSC Mainnet (Chain ID 56), make these changes:Use Real Token Addresses
Replace mock tokens with mainnet addresses:
| Token | Mainnet Address |
|---|---|
| USDT (BEP-20) | 0x55d398326f99059fF775485246999027B3197955 |
| USDC (BEP-20) | 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d |
| WBNB | 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c |
Use Real Chainlink Feeds
Replace mock price feeds with mainnet Chainlink oracles:
| Pair | Mainnet Feed Address |
|---|---|
| BNB/USD | 0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE |
| BTC/USD | 0x264990fbd0A4796A3E3d8E37C4d5F87a3aCa5Ebf |
| ETH/USD | 0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e |
Find all Chainlink BSC feeds at data.chain.link.
Verify and Configure
- Verify contracts on BscScan Mainnet
- Configure all token price feeds
- Set the fee recipient to your production address
- Update the platform backend with the new contract addresses
Hardhat Configuration
Examplehardhat.config.ts for BSC networks:
Troubleshooting
Transaction reverts with 'Stale price'
Transaction reverts with 'Stale price'
The Chainlink oracle data is older than the staleness threshold (default 1 hour). On testnet, mock feeds may not auto-update. Call the mock feed’s
updateAnswer() to refresh the price, or increase the staleness threshold.'Token not configured' error
'Token not configured' error
The token has not been registered with the price feed contract. Call
priceFeed.configureToken() to register it.'Insufficient allowance' on createPayment
'Insufficient allowance' on createPayment
The payer has not approved the escrow contract to spend their tokens. The payer must call
token.approve(escrowAddress, amount) before creating a payment.Verification fails on BscScan
Verification fails on BscScan
Ensure you are using the exact same compiler version and optimization settings as the deployment. Check that constructor arguments match exactly.