Architecture
iStory uses four core smart contracts deployed on Base Sepolia (Chain ID: 84532) to power Web3 features:eStoryToken
ERC20 utility token with 100M max supply
StoryProtocol
Tipping and paywall payments
StoryNFT
ERC721 story collections with royalties
PrivateVerifiedMetrics
Chainlink CRE-attested quality metrics
Deployed Addresses
All contracts are deployed on Base Sepolia (Chain ID: 84532).Contract Interactions
Using Wagmi Hooks
iStory provides React hooks for all contract operations:app/hooks/useEStoryToken.ts
Direct Contract Calls
Using Viem
Security Features
Access Control
Access Control
All contracts use OpenZeppelin’s
AccessControl for role-based permissions:- MINTER_ROLE: Can mint new tokens (eStoryToken)
- PAUSER_ROLE: Can pause/unpause transfers (eStoryToken, StoryProtocol)
- DEFAULT_ADMIN_ROLE: Can manage roles and update settings
Reentrancy Protection
Reentrancy Protection
StoryProtocol uses OpenZeppelin’s
ReentrancyGuard on all payment functions:nonReentrantmodifier prevents reentrancy attacksSafeERC20prevents silent transfer failures
Pausable
Pausable
Critical contracts can be paused in emergencies:
- eStoryToken: Blocks all transfers when paused
- StoryProtocol: Blocks tips and paywall payments
Supply Cap
Supply Cap
eStoryToken enforces a hard cap:Minting reverts if it would exceed this limit.
Network Configuration
All contracts are deployed on Base Sepolia testnet. Ensure your wallet is connected to the correct network:
- Chain ID: 84532
- RPC URL: https://sepolia.base.org
- Block Explorer: https://sepolia.basescan.org
Add Base Sepolia to Wagmi
lib/wagmi.ts
Testing Contracts
Hardhat Commands
Terminal
Local Development
Terminal
Gas Optimization
All contracts follow gas-efficient patterns:- Immutable variables:
storyTokenin StoryProtocol saves 2100 gas per read - Minimal storage: PrivateVerifiedMetrics stores only hashes on-chain
- Efficient packing: Structs use appropriate uint sizes (uint8, uint96)
- Safe arithmetic: Solidity 0.8.20+ has built-in overflow checks
Events for Indexing
All contracts emit events for off-chain indexing:Key Events
Next Steps
eStoryToken
Learn about the $STORY utility token
StoryProtocol
Implement tipping and paywalls
StoryNFT
Mint story collection NFTs
PrivateVerifiedMetrics
Use Chainlink CRE for verified metrics