15 Smart Contracts

Blockchain Infrastructure

InteractAI's smart contract architecture enables trustless, transparent, and efficient reward distribution at scale through innovative use of Merkle tree verification.


Contract Architecture

Three Core Contracts

CampaignRewardsMerkle (Primary)

  • Deployed on BSC

  • Manages campaign rewards

  • Merkle tree verification

  • Status: Deployed and Verified

  • Campaign creation and management

  • Merkle-based reward distribution

  • Platform fee collection

  • Budget management

MultiTokenStaking

  • Deployed on BSC

  • Manages staking pools

  • Multi-token support

  • Status: Deployed and Verified

  • Flexible duration staking (30-365 days)

  • Multi-token reward pools

  • Dynamic APY (5-40%)

  • Early withdrawal penalties

IAIToken (BEP20)

  • Standard ERC20 implementation

  • Transfer and allowance functions

  • Burn capability

  • 18 decimal precision


CampaignRewardsMerkle Contract

Core Functionality

Campaign Creation:

  • Brand deposits budget + platform fee (10-15%)

  • Sets start/end dates

  • Specifies reward token (IAI or other BEP20)

  • Campaign ID generated on-chain

Merkle Root Updates:

  • Platform submits aggregated engagement data

  • Merkle root stored on-chain

  • Timestamp recorded

  • Enables batch verification

Reward Claims:

  • Users claim with Merkle proof

  • Contract verifies proof against root

  • Tokens transferred automatically

  • Prevents double-claiming

Platform-Assisted Claims:

  • Platform can claim on behalf of users

  • Zero gas fees for users

  • Batch processing for efficiency

  • Same security guarantees

Key Features

Role-Based Access:

  • ADMIN_ROLE: Contract administration

  • MERKLE_SUBMITTER_ROLE: Root updates

  • PLATFORM_ROLE: Assisted claims

  • Granular permission control

Security Mechanisms:

  • ReentrancyGuard: Prevents reentrancy attacks

  • Pausable: Emergency stop capability

  • AccessControl: Role-based permissions

  • SafeERC20: Secure token transfers

Gas Optimization:

  • Merkle trees reduce verification cost

  • Batch claiming for multiple rewards

  • Efficient storage patterns

  • Minimal on-chain computation

Economic Model

Platform Fees:

  • Default: 10% of campaign budget

  • Adjustable by admin

  • Collected at campaign creation

  • Transparent on-chain

Budget Management:

  • Total budget locked in contract

  • Distributed amount tracked

  • Remaining balance calculable

  • Refund mechanism for unused funds

Campaign Finalization:

  • Creator can finalize after end date

  • Unused funds returned

  • Platform fee retained

  • Campaign marked complete


MultiTokenStaking Contract

Staking Mechanism

Pool Structure:

  • Each pool supports one staking token

  • Multiple reward tokens per pool

  • Configurable reward rates

  • Active/inactive status

1

Staking Process

  • User approves token spending

  • Selects pool and duration (30-365 days)

  • Tokens locked in contract

  • Rewards accrue automatically

  • Withdrawal after duration or with penalty

Reward Calculation:

  • Time-based accrual

  • Proportional to stake amount

  • Multiple reward tokens supported

  • Compound-ready (future)

APY Structure

Duration-Based Returns:

Duration
APY
Lock Period
Early Penalty

30 days

5%

1 month

20%

90 days

15%

3 months

20%

180 days

25%

6 months

20%

365 days

40%

1 year

20%

Economic Sustainability:

  • Rewards funded from platform revenue

  • Decreasing emissions over time

  • Transition to revenue-sharing model

  • Long-term viability

Security Features

Access Control:

  • Owner-only pool creation

  • Owner-only rate updates

  • User-only withdrawals

  • Emergency withdrawal option

Safety Mechanisms:

  • ReentrancyGuard protection

  • Minimum/maximum staking periods

  • Overflow protection

  • Validated inputs


IAIToken Contract

Token Specifications

Standard Compliance:

  • BEP20 (ERC20 compatible)

  • 18 decimal places

  • 1,000,000,000 total supply

  • Mintable: Yes (fixed supply)

  • Burnable: Yes

Core Functions:

  • transfer(): Send tokens

  • approve(): Allow spending

  • transferFrom(): Delegated transfer

  • burn(): Permanent removal

Token Economics

Supply Management:

  • Fixed total supply at deployment

  • No minting capability

  • Burn function for deflationary pressure

  • Transparent on-chain tracking

Distribution Control:

  • Initial distribution via deployment

  • Vesting handled off-chain or via separate contracts

  • Transparent allocation tracking

  • Auditable on BSCScan


Merkle Tree Innovation

Why Merkle Trees?

Traditional Approach Problem:

  • Each reward = separate transaction

  • 1M rewards = 1M transactions

  • Gas cost: $100K-500K

  • Unsustainable at scale

Merkle Solution:

  • Aggregate all rewards in tree

  • Single root hash on-chain

  • Users prove inclusion with path

  • Gas cost: $10-25K for 1M rewards

  • 99.99% cost reduction

How It Works

1

Off-Chain (Platform)

  • Collect verified engagements

  • Create leaf for each (user, index, amount)

  • Build Merkle tree

  • Calculate root hash

  • Submit root to contract

2

On-Chain (Smart Contract)

  • Store Merkle root

  • Verify user-provided proofs

  • Check against stored root

  • Transfer tokens if valid

  • Mark as claimed

3

User Experience

  • Engage with campaign

  • Wait for verification

  • Claim rewards (zero gas)

  • Tokens received instantly

Security Guarantees

Tamper-Proof:

  • Any data change invalidates proof

  • Cryptographically secure

  • Transparent verification

  • Auditable on-chain

Double-Claim Prevention:

  • Each claim marked on-chain

  • Attempted re-claims rejected

  • Per-user, per-index tracking

  • Permanent record


Contract Deployment

Network Details

Binance Smart Chain Mainnet:

  • Chain ID: 56

  • RPC: https://bsc-dataseed.binance.org

  • Explorer: https://bscscan.com

  • Block Time: 3 seconds

Smart Contract Addresses

IAI Token Contract:

CampaignRewardsMerkle Contract:

  • Address: TBA

  • Network: BSC Mainnet

  • Standard: Custom

  • Verified: View on BSCScan - https://bscscan.com

MultiTokenStaking Contract:

  • Address: TBA

  • Network: BSC Mainnet

  • Standard: Custom

  • Verified: View on BSCScan—https://bscscan.com/address/

Verification & Audits

Source Code Verification:

  • Verified on BSCScan

  • Open-source on GitHub

  • Transparent implementation

  • Community auditable

Security Audits:

  • Third-party audit completed

  • No critical vulnerabilities

  • Best practices followed

  • Regular security reviews

Bug Bounty:

  • Ongoing program

  • Rewards for vulnerability disclosure

  • Responsible disclosure policy

  • Community security engagement


Gas Optimization Strategies

Design Patterns

Efficient Storage:

  • Packed structs

  • Minimal storage writes

  • Batch operations

  • Event emission over storage

Computation Optimization:

  • Off-chain heavy computation

  • On-chain verification only

  • Merkle proofs vs. full data

  • Minimal loops

Transaction Batching:

  • Multiple claims in one transaction

  • Reduced per-claim overhead

  • Lower total gas cost

  • Better user experience

Cost Comparison

Single Reward Claim:

  • Traditional: ~50,000 gas ($2.50 at 100 gwei)

  • Merkle: ~35,000 gas ($1.75 at 100 gwei)

  • Savings: 30%

Batch Claim (10 rewards):

  • Traditional: 500,000 gas ($25)

  • Merkle: 150,000 gas ($7.50)

  • Savings: 70%

Platform-Assisted (Zero User Gas):

  • User cost: $0

  • Platform cost: Amortized across users

  • User savings: 100%


Upgrade Strategy

Current Approach

Non-Upgradeable Contracts:

  • Immutable after deployment

  • Transparent operation

  • No admin backdoors

  • Trust through code

New Feature Deployment:

  • Deploy new contracts

  • Migrate functionality

  • Maintain backward compatibility

  • User opt-in for new features

Future Considerations

Proxy Pattern (If Needed):

  • Upgradeable logic

  • Preserved state

  • Governance-controlled

  • Emergency fixes possible

Governance Integration:

  • DAO-controlled upgrades

  • Community voting

  • Timelock delays

  • Transparent process


Integration Guide

For Developers

1

Campaign Creation

  • Approve token spending

  • Call createCampaign()

  • Receive campaign ID

  • Monitor events

2

Merkle Root Submission

  • Aggregate engagement data

  • Build Merkle tree

  • Call updateMerkleRoot()

  • Emit update event

3

Reward Claiming

  • Generate Merkle proof

  • Call claimReward()

  • Verify transaction

  • Update UI

For Users

1

Staking

  • Approve IAI spending

  • Select pool and duration

  • Confirm transaction

  • Track rewards

2

Claiming Rewards

  • View available rewards

  • Click claim button

  • Sign transaction (or platform claims)

  • Receive tokens


Risk Mitigation

Smart Contract Risks

Code Vulnerabilities:

  • Mitigation: Audits, testing, best practices

  • Contingency: Bug bounty, emergency pause

Economic Attacks:

  • Mitigation: Rate limits, validation, monitoring

  • Contingency: Circuit breakers, admin controls

Oracle Failures:

  • Mitigation: Multiple data sources, validation

  • Contingency: Manual intervention capability

Operational Risks

Key Management:

  • Multi-sig for admin functions

  • Hardware wallet storage

  • Backup procedures

  • Access controls

Network Issues:

  • Multiple RPC endpoints

  • Automatic failover

  • Transaction monitoring

  • Retry mechanisms


Conclusion

InteractAI's smart contract architecture delivers trustless, efficient, and scalable reward distribution through innovative use of Merkle trees and battle-tested security patterns.

Key Strengths
  • ✅ 99.99% gas cost reduction (Merkle trees)

  • ✅ Zero gas fees for users (platform-assisted claims)

  • ✅ Audited and verified contracts

  • ✅ Role-based access control

  • ✅ Emergency pause capability

  • ✅ Transparent on-chain operations

Business Impact: Enables sustainable economics while providing enterprise-grade security and user experience.

Last updated