A simple stablecoin POC backed by Bhutan's Bitcoin reserves, deployed on the Sepolia testnet.
DragonCoin is an ERC20 token that demonstrates a simple concept of a stablecoin backed by Bhutan's Bitcoin reserves. This POC includes:
- Basic Bitcoin reserves tracking
- Simple minting and burning functionality
- Pausable token transfers for emergency situations
- Role-based access control for administrators and minters
- Node.js (v14+ recommended)
- npm or yarn
- An Ethereum wallet with Sepolia ETH for gas
- Clone the repository
git clone <repository-url>
cd dragon-coin-sepolia- Install dependencies
npm install- Create a
.envfile with your private key
PRIVATE_KEY=your_private_key_without_0x_prefix
- Deploy the DragonCoin contract to Sepolia
npx hardhat run scripts/deploy.js --network sepolia- Update the contract address in all scripts after deployment
- Update Bitcoin reserves
npx hardhat run scripts/updateReserves.js --network sepolia- Update BTC/USD exchange rate
npx hardhat run scripts/updateExchangeRate.js --network sepolia- Update collateral ratio
npx hardhat run scripts/updateCollateralRatio.js --network sepolia- Mint tokens (respecting the collateralization limit)
npx hardhat run scripts/mintTokens.js --network sepolia- Check stablecoin status
npx hardhat run scripts/checkStatus.js --network sepolia- Grant minter role to another address
npx hardhat run scripts/grantMinter.js --network sepolia- Grant oracle role to an address
npx hardhat run scripts/grantOracle.js --network sepolia- Revoke minter role from an address
npx hardhat run scripts/revokeMinter.js --network sepoliaDragonCoin includes a full-featured REST API that allows you to interact with the smart contract through HTTP requests.
- Navigate to the API directory
cd api- Start the API server with all features
start_full_api.batThis will:
- Set up the Python virtual environment if needed
- Test the connection to the smart contract
- Update contract addresses from your .env file
- Run API endpoint tests if requested
- Start the API server
The API provides comprehensive endpoints for all contract operations:
- GET /status - Get current contract status, reserves, and supply
- GET /balance/{address} - Get token balance for an address
- POST /mint - Mint new tokens to an address
- POST /bulk-mint - Mint tokens to multiple addresses
- POST /update-reserves - Update Bitcoin reserves
- POST /update-collateral-ratio - Update collateral ratio
- POST /update-exchange-rate - Update BTC/USD exchange rate
- GET /minter-role/{address} - Check if address has minter role
- GET /oracle-role/{address} - Check if address has oracle role
- POST /grant-role - Grant a role to an address
- POST /revoke-role - Revoke a role from an address
- GET /events - Get contract events (transfers, mints, etc.)
- POST /pause - Pause all token transfers
- POST /unpause - Unpause token transfers
Once the server is running, you can access:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
- Dashboard: http://127.0.0.1:8000/static/index.html
For more details, see the API README.