This guide provides step-by-step instructions for deploying the complete Spout RWA (Real World Asset) token system on Base Sepolia testnet.
- Node.js and npm installed
- Hardhat configured with Base Sepolia network
- Private key with sufficient ETH for deployment
- Chainlink Functions subscription (for market data)
Before starting deployment, check if you already have components deployed:
npx hardhat run scripts/deployment/05-skip-if-already-registered.ts --network base-sepoliaFirst, deploy the T-REX infrastructure components:
# 1. Deploy token logic
npx hardhat run scripts/deployment/01-deploy-token-logic.ts --network base-sepolia
# 2. Deploy compliance logic
npx hardhat run scripts/deployment/02-deploy-compliance-logic.ts --network base-sepolia
# 3. Deploy registry logics
npx hardhat run scripts/deployment/03-deploy-registry-logics.ts --network base-sepolia
# 4. Deploy implementation authority
npx hardhat run scripts/deployment/04-deploy-implementation-authority.ts --network base-sepolia
# 5. Register implementations (with error handling)
npx hardhat run scripts/deployment/05-register-implementations.ts --network base-sepolia
# 6. Verify implementation authority
npx hardhat run scripts/deployment/06-verify-ia.ts --network base-sepolia
# 7. Deploy TREX factory
npx hardhat run scripts/deployment/07-deploy-trex-factory.ts --network base-sepolia# 8. Deploy Spout token logic
npx hardhat run scripts/deployment/01b-deploy-spout-token-logic.ts --network base-sepolia
# 9. Deploy market data consumer
npx hardhat run scripts/deployment/08-deploy-market-data-consumer.ts --network base-sepolia# 10. Deploy complete Spout RWA token suite
npx hardhat run scripts/deployment/09-deploy-spout-token-suite.ts --network base-sepoliaIf you encounter this error during step 5, it means the Implementation Authority already has version 1.0.0 registered. This is normal if you've run the deployment before.
Solution: Use the status check script instead:
npx hardhat run scripts/deployment/05-skip-if-already-registered.ts --network base-sepoliaIf the status shows all implementations are set, you can skip to step 7 (TREX Factory deployment).
If you encounter gas estimation failures:
- Check your ETH balance - Ensure you have sufficient ETH for deployment
- Increase gas limits - The scripts include dynamic gas adjustment
- Check network congestion - Base Sepolia can be congested during peak times
If a contract is already deployed, the script will show the existing address. You can continue with the next step.
-
Create a Functions subscription:
- Go to Chainlink Functions
- Create a new subscription
- Fund it with LINK tokens
-
Add your contract as consumer:
- Use the
FunctionAssetConsumeraddress from step 8 - Add it as an authorized consumer in your subscription
- Use the
-
Get your subscription ID:
- Note the subscription ID for use in market data requests
Create a .env file with:
PRIVATE_KEY=your_private_key_here
BASESCAN_API_KEY=your_basescan_api_key_here
CHAINLINK_FUNCTIONS_SUBSCRIPTION_ID=your_subscription_id_hereAfter deployment, you'll have these key addresses:
- TREX Factory: Main factory for deploying token suites
- Spout Token: Your RWA token contract
- Market Data Consumer: Chainlink Functions integration
- Identity Registry: KYC/AML management
- Compliance: Transfer restrictions and rules
// Set bond parameters
const maturityDate = Math.floor(Date.now() / 1000) + (365 * 24 * 60 * 60); // 1 year
const couponRate = 500; // 5% annual rate
await spoutToken.initializeRWA(maturityDate, couponRate, marketDataConsumerAddress);// Add compliance modules as needed
await modularCompliance.addModule(complianceModuleAddress);// Add trusted issuers
await trustedIssuersRegistry.addTrustedIssuer(issuerAddress, [1]);Run the comprehensive test suite:
# Test Spout contracts
npx hardhat test test/Spoutv1.ts
# Test all contracts
npx hardhat test- Interest Calculation: Automatic interest calculation based on time held
- Maturity Management: Bond maturity date tracking
- Market Data Integration: Real-time price feeds via Chainlink
- Compliance: ERC-3643 compliant with KYC/AML support
- Transfer Validation: RWA-specific transfer restrictions
- Batch Operations: Efficient batch interest release
- Maturity Date: When the bond matures
- Coupon Rate: Annual interest rate in basis points
- Decimals: 6 decimals (standard for bond tokens)
- Initial Supply: Configurable initial token supply
- Access Control: Only owner can initialize RWA parameters
- Input Validation: All parameters are validated
- Reentrancy Protection: Uses OpenZeppelin's ReentrancyGuard
- Upgradeable: Uses proxy pattern for future upgrades
Use these scripts to check deployment status:
# Check Implementation Authority status
npx hardhat run scripts/deployment/05-skip-if-already-registered.ts --network base-sepolia
# Check specific contract deployments
npx hardhat run scripts/deployment/06-verify-ia.ts --network base-sepoliaVerify your contracts on BaseScan:
npx hardhat verify --network base-sepolia CONTRACT_ADDRESS- Frontend Integration: Build a web interface for token management
- Compliance Configuration: Set up specific compliance rules
- Market Data: Configure additional market data sources
- Monitoring: Set up monitoring and alerting systems
For issues or questions:
- Check the test files for usage examples
- Review the contract documentation
- Open an issue in the repository
Note: This deployment guide is for Base Sepolia testnet. For mainnet deployment, ensure all security measures are in place and contracts are thoroughly audited.