Skip to content

HedgeLords/dragon-coin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dragon Coin (DRGN)

A simple stablecoin POC backed by Bhutan's Bitcoin reserves, deployed on the Sepolia testnet.

Overview

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

Getting Started

Prerequisites

  • Node.js (v14+ recommended)
  • npm or yarn
  • An Ethereum wallet with Sepolia ETH for gas

Installation

  1. Clone the repository
git clone <repository-url>
cd dragon-coin-sepolia
  1. Install dependencies
npm install
  1. Create a .env file with your private key
PRIVATE_KEY=your_private_key_without_0x_prefix

Deployment

  1. Deploy the DragonCoin contract to Sepolia
npx hardhat run scripts/deploy.js --network sepolia
  1. Update the contract address in all scripts after deployment

Managing the Stablecoin

  1. Update Bitcoin reserves
npx hardhat run scripts/updateReserves.js --network sepolia
  1. Update BTC/USD exchange rate
npx hardhat run scripts/updateExchangeRate.js --network sepolia
  1. Update collateral ratio
npx hardhat run scripts/updateCollateralRatio.js --network sepolia
  1. Mint tokens (respecting the collateralization limit)
npx hardhat run scripts/mintTokens.js --network sepolia
  1. Check stablecoin status
npx hardhat run scripts/checkStatus.js --network sepolia
  1. Grant minter role to another address
npx hardhat run scripts/grantMinter.js --network sepolia
  1. Grant oracle role to an address
npx hardhat run scripts/grantOracle.js --network sepolia
  1. Revoke minter role from an address
npx hardhat run scripts/revokeMinter.js --network sepolia

API Documentation

DragonCoin includes a full-featured REST API that allows you to interact with the smart contract through HTTP requests.

Starting the API

  1. Navigate to the API directory
cd api
  1. Start the API server with all features
start_full_api.bat

This 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

API Endpoints

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

API Documentation

Once the server is running, you can access:

For more details, see the API README.

About

bhutans crypto currency backed by its BTC reserves

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors