Collect is a receiver-pays messaging protocol that leverages Ethereum's EIP-4844 blob storage for cost-effective encrypted message delivery. Recipients pay to decrypt messages, creating a spam-resistant communication system.
- π¦ EIP-4844 Blob Storage: Store up to 125 KB messages in blob transactions
- π End-to-End Encryption: AES-256-GCM encryption with ECDH key exchange
- π° Receiver-Pays Model: Recipients pay fees to decrypt messages
- β½ Account Abstraction: ERC-4337 paymaster for gasless posting
- π Dynamic Pricing: Fees adjust based on blob base fee and congestion
- π Production Ready: Comprehensive test suite with 100% passing tests
# Clone the repository
git clone https://github.com/douglance/collect.git
cd collect
# Check prerequisites
./check-prerequisites.sh
# Run complete test suite
./test-all.sh
# Try the interactive demo
./demo.js
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Sender ββββββΆβ MessageHub ββββββΆβ Blobs β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β
βΌ
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Receiver ββββββΆβ FeeOracle β β Paymaster β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
- MessageHub: Core messaging contract for posting and opening messages
- FeeOracle: Dynamic fee calculation based on blob base fees
- CollectPaymaster: ERC-4337 paymaster for sponsored transactions
- API Gateway: RESTful endpoints for message operations
- Blob Service: Handles blob storage and retrieval
- Relayer: Manages transaction submission
- Cost Oracle: Monitors blob base fees
- React/Next.js 14 inbox application
- Wallet integration with wagmi
- Real-time message display
- Node.js 18+
- Foundry
- Docker & Docker Compose
- MetaMask or compatible wallet
-
Install dependencies
npm install cd client && npm install
-
Configure environment
cp .env.example .env # Edit .env with your settings
-
Deploy contracts locally
# Start local blockchain anvil # Deploy contracts forge script script/Deploy.s.sol:DeployScript --rpc-url http://localhost:8545 --broadcast
-
Start services
docker-compose up
-
Start frontend
cd client npm run dev
# Run all smart contract tests
forge test --gas-report
# Run specific test suite
forge test --match-contract MessageHubTest -vvv
# Run complete test suite
./test-all.sh
# Interactive demo
./demo.js
# Load testing (50 messages)
./load-test.js
- β 68 smart contract tests (100% passing)
- β Service integration tests
- β End-to-end flow tests
- β Load testing (>5 msg/sec throughput)
-
Set environment variables
export PRIVATE_KEY=<your-private-key> export BASE_SEPOLIA_RPC=https://sepolia.base.org
-
Deploy contracts
make deploy-testnet
-
Verify deployment
forge script script/Verify.s.sol:VerifyScript --rpc-url $BASE_SEPOLIA_RPC
See DEPLOYMENT.md for detailed instructions.
// Send encrypted message
const messageId = await messageHub.post(
blobHash, // Blob transaction hash
encryptedKey, // Encrypted AES key
sizeKB, // Message size
recipientAddress // Recipient
);
// Recipient opens message
await messageHub.open(messageId, { value: fee });
// Decrypt with retrieved key
const decryptedMessage = decrypt(encryptedData, key);
Operation | Gas Used | Cost (at 30 gwei) |
---|---|---|
Post Message | ~180,000 | ~0.0054 ETH |
Open Message | ~50,000 | ~0.0015 ETH |
Update Fee | ~35,000 | ~0.0011 ETH |
- AES-256-GCM encryption for message content
- ECDH key exchange for secure key sharing
- Keys stored only in memory, never persisted
- Comprehensive access controls
- Pausable contracts for emergency response
- Testing Guide - Complete testing documentation
- Deployment Guide - Production deployment instructions
- PRD Specification - Product requirements document
- API Reference - API documentation
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Run tests (
forge test
) - Commit changes (
git commit -m 'Add amazing feature'
) - Push to branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Built on Foundry
- Leverages EIP-4844 blob transactions
- Implements ERC-4337 account abstraction
- Deployed on Base Layer 2
Built with β€οΈ for the Ethereum ecosystem