A modern, user-friendly interface for showcasing the MockRandomnessReceiver smart contract from the randomness-solidity library. This platform demonstrates how to interact with verifiable randomness from the dcipher threshold network.
- Live Demo: Interactive interface to test all contract functionalities
- Contract Information: Comprehensive overview of contract features and security
- Random Anime Character Generation: Demo showcasing
random anime char generationvia drand-randomness - Randomly and Fairly Split Bills: Another Demo to split bills on a dinner table in a
random & fairway
The interface showcases all the key functionalities of the MockRandomnessReceiver contract:
- Direct Funding Randomness: Request randomness by paying per request
- Subscription Management: Create and manage subscriptions for cost-effective randomness
- Real-time State Monitoring: View contract state including randomness, request IDs, and subscriptions
- Transaction Handling: Complete workflow from request to fulfillment
Before running this interface, you need:
-
Deployed MockRandomnessReceiver Contract: The smart contract must be deployed on either of the supported Networks: See Here
-
Wallet with Test ETH: Sufficient ETH for gas fees and randomness requests.
- Environment Variables: Set up your Alchemy API key and WalletConnect project ID
npm installCreate a .env.local file in the root directory:
NEXT_PUBLIC_ALCHEMY_KEY=your_alchemy_api_key_here
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id_hereEdit src/config.ts and update:
// Replace with your deployed contract address
export const CONTRACT_ADDRESS = '0xYourDeployedContractAddress';
// Update with your WalletConnect project ID
export const config = getDefaultConfig({
appName: 'VRF Interface',
projectId: 'YOUR_ACTUAL_PROJECT_ID', // Get from https://cloud.walletconnect.com
chains: [baseSepolia], // deployed network
ssr: true,
transports: {
[baseSepolia.id]: http(`https://base-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_KEY}`)
} // based on the deployed network, id and get url from alchemy dashboard
});npm run dev- Open http://localhost:3000 to view the interface.
- Click the "Connect Wallet" button in the header
- Choose your preferred wallet (MetaMask, WalletConnect, etc.)
- Ensure you're connected to supported networks like Base Sepolia testnet/FilecoinCalinet
- Navigate to the "Live Demo" tab
- Click "Request Randomness (Direct Funding)"
- Confirm the transaction in your wallet
- Wait for the oracle to fulfill your request (may take several minutes sometimes :)
- Click "Create Subscription"
- Once created, you can request randomness using the subscription
The interface provides real-time updates of:
- Current randomness value
- Latest request ID
- Subscription status
- Contract owner
- Randomness sender address
src/
├── app/ # Next.js app directory
| |__ ranime/
| |__ page.tsx # anime character generator using the randomness val
│ ├── layout.tsx # Root layout with providers
│ ├── page.tsx # Main page component
│ └── globals.css # Global styles
├── components/ # React components
│ ├── Header.tsx # Navigation header
│ ├── RandomnessDemo.tsx # Main demo interface
│ └── ContractInfo.tsx # Contract information display
├── config.ts # Contract ABI and configuration
├── providers.tsx # React Query and Wagmi providers
└── wagmi-config.ts # Wagmi configuration
- Next.js 15: React framework with app router
- Tailwind CSS: Utility-first CSS framework
- Wagmi: React hooks for Ethereum
- RainbowKit: Wallet connection UI
- React Query: Data fetching and state management
- randomness-js: JavaScript SDK for randomness-solidity
- ethers.js: Ethereum library for interactions
randomness: Get current randomness valuerequestId: Get latest request IDsubscriptionId: Get subscription IDowner: Get contract ownerrandomnessSender: Get randomness sender address
rollDiceWithDirectFunding: Request randomness with direct paymentrollDiceWithSubscription: Request randomness using subscription
- Verifiable Randomness: All randomness comes from the cryptographically secure dcipher network
- Access Control: Only designated randomness sender can provide values
- Request Validation: Request IDs are validated for proper callback handling
- Owner Controls: Critical functions restricted to contract owner
- Contract Not Found: Ensure the contract address is correct and deployed
- Transaction Fails: Check you have sufficient ETH for gas and randomness fees
- Randomness Not Received: Oracle fulfillment may take several minutes
- Wallet Connection Issues: Ensure you're on the correct network
Enable console logging to debug issues:
- Check browser console for error messages
- Verify contract calls in your wallet
- Monitor transaction status on Base Sepolia explorer
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Documentation: randomness-solidity docs
- GitHub: randomness-solidity repository
Built randomly ❤️ using randomness-solidity.🙂😄