Simple Relayer with 50 private keys
Current Block
Loading...
Counter Value
How It Works:
- The relayer uses multiple private keys to send transactions in parallel
- When you click Increment, the request is queued on the server, which is a simple nextjs api route
- Available private keys are assigned to process transactions from the queue
- Each transaction calls the
increment()function on the YourContract - This architecture allows for high throughput without transaction conflicts
Your Transactions
0
Transactions you have sent this session
Behind the Scenes: How the Relayer Works
1
User clicks Increment
Frontend sends a POST request to /api/relayer/increment
2
Server queues the transaction
Tx 1
Tx 2
Tx 3
3
Multiple wallets process transactions in parallel
Wallet 1: Active
Wallet 2: Active
Wallet 3: Active
Wallet 4: Idle
4
Transactions sent to Monad blockchain
YourContract.increment() // Increases counter by 1Result: High throughput of transactions without conflicts, allowing the counter to increment rapidly even under heavy load
How to Use This Repo
Getting Started
- Clone the repository:
git clone https://github.com/portdeveloper/hackhazards-example - Install dependencies:
yarn install - cd packages/foundry:
cd packages/foundry - Install foundry dependencies:
forge install - Open a new terminal
- Start the development server:
yarn start
Project Structure
- packages/nextjs: Frontend application built with Next.js
- packages/foundry: Smart contracts and deployment scripts
Using the Relayer
This project demonstrates a high-throughput transaction relayer system:
- Configure private keys in
.envfile (see.env.example) - The relayer automatically processes transaction requests from the queue
- Customize the relayer logic in
packages/nextjs/api/relayer/increment/route.ts
Customizing Smart Contracts
- Edit contracts in
packages/foundry/contracts - Deploy to your local node(anvil)
yarn deploy - Deploy to Monad Testnet with
yarn deploy --network monad_testnet - Test with
yarn test
Need Help?
Check out the Scaffold-ETH 2 Documentation for Scaffold-ETH 2 related questions or join Monad Developer Discord for any question related to Monad.