DGRID is a decentralized smart AI network built on BNB Smart Chain (BSC) and other EVM-compatible networks.
The current contracts cover:
- USDT-based node NFT purchases with server-signed orders
- Referral commission accounting
- Transfer-gated node NFTs with staking and jail states
- Node NFT staking with multi-token rewards
- DGAI staking by node and lock tier
- User top-ups with BNB, stablecoins, or configured DGAI
- Server-triggered automatic top-ups with supported stablecoins
- DGAI/USDT TWAP pricing through PancakeSwap V3
- AI Arena winner upload and reward claiming
contracts/Dgrid.sol: USDT node purchase, referral commission, node NFT minting, pause and emergency controlscontracts/DgridNode.sol: ERC-721 node NFT with public-transfer gating and staked/jailed flagscontracts/DgridStakePool.sol: node NFT staking, reward harvesting, DGAI accounting, pre-claim flow, and DGAI reward restakingcontracts/DGAIStaking.sol: DGAI staking by node and lock tier, unstake cooling, reward claiming, node commission, and jail controlscontracts/DgridTopUp.sol: user top-ups paid with BNB, supported stablecoins, or configured DGAIcontracts/DgridTopUpAuto.sol: server-triggered automatic top-ups using supported tokenscontracts/DgridPriceFeed.sol: PancakeSwap V3 TWAP adapter for DGAI/USDT pricingcontracts/ChainlinkPriceFeed.sol: Chainlink price adapter with cache, heartbeat, deviation guard, and 18-decimal scalingcontracts/DgridAIArena.sol: user activation, server-uploaded winners, and multi-token reward claimscontracts/DGAI.sol: capped mintable DGAI ERC-20contracts/Proxy.sol: OpenZeppelin transparent proxy imports for deployment
- Owner: configures protocol parameters, assets, rewards, oracles, pause state, and emergency operations
- Server: signs or operates purchase orders, staking actions, pre-stake validation, jail/unjail actions, AI Arena winners, and automatic top-ups
- Dev: receives node purchase proceeds and top-up funds
- Treasury: source wallet for server-authorized DGAI pre-stake transfers
- User: buys nodes, stakes NFTs or DGAI, tops up, joins AI Arena, and claims rewards
- Referrer: receives node purchase commission
buyNode(...)currently supports purchases with the configuredusdttoken only.- Server signature includes
chainId,address(this),usdt, order data,nodePrice, andgasAmountPerNode. - Payment amount is:
nodePrice * nodeCount * 1e18 + gasAmountPerNode * nodeCount * 1e18- Referral commission is calculated from the node-price portion only.
- The net amount is transferred to
dev; commission stays claimable for the referrer. - Node NFTs are minted sequentially to the target user.
- Users stake owned
DgridNodeNFTs with a server-signeddeposit(...). - Rewards accrue per block across configured reward tokens.
- Users can
harvest()available rewards. - Unstake is controlled by
unstakeEnabled. - Server can jail nodes; users can unjail with a server signature.
- DGAI rewards can be restaked into
DGAIStaking.
- Owner creates staking nodes.
- Users stake DGAI into a selected node and lock tier.
- Lock tiers use configurable fixed rates for reward weight.
- Users can claim rewards, restake rewards, change nodes, and request unstake.
- Unstaked principal is released after the lock-tier cooling period.
- Node owners can claim node commission.
- Emergency withdrawal is limited to surplus DGAI above user principal.
- BNB top-ups use
ChainlinkPriceFeed.fetchPrice(address(0)). - Stablecoin top-ups are normalized by token decimals.
- DGAI top-ups use
DgridPriceFeed.getDGAITwapPrice18(). DgridTopUpAuto.autoTopUp(...)can only be called byserver; it transfers supported tokens from the user todevand records the normalized USD value.userTopUpAmount[user]stores cumulative 18-decimal USD value.
- Users call
activate()once before receiving rewards. - Server uploads winners by round with supported reward tokens.
- Users claim rewards with
claimReward(). getShortfall(token)reports reward-token funding gaps.
ChainlinkPriceFeedhandles external asset prices such as BNB.DgridPriceFeedreads PancakeSwap V3 observations to calculate the DGAI/USDT TWAP.- Prices are returned in 18 decimals.
- Call
Dgrid.initializeV2(usdt)before node purchases. - Configure the native BNB Chainlink feed as
asset == address(0)before BNB top-ups. - Call
DgridTopUp.initializeV2(DGAI, priceFeed)before DGAI top-ups. - Use
DgridTopUp.setDGridPriceFeed(...)if the DGAI price feed needs to be updated. - Configure
DgridTopUpAuto.initialize(owner, dev, server, usdt)before automatic top-ups. DGAIStakingstarts paused after initialization and must be unpaused before user staking.DgridNodetransfers are blocked while public transfers are disabled, or while a token is staked or jailed.- Anyone can call
Dgrid.claimCommission(user, assets[]); funds are sent touser.
Install dependencies:
npm installCompile:
npx hardhat compileSee audits/**.pdf.