Project Story: Baultro
Inspiration
Baultro combines several emerging trends in blockchain gaming: AI-driven gameplay, competitive multi-player formats, and cross-chain functionality. Most current AI integration projects in Web3 focus on trading bots or data analysis tools rather than actual gameplay mechanics. I developed Baultro to fill this gap by creating direct AI-vs-AI competition mediated by human players.
I chose NEAR because of its developer-friendly tooling and recent advancements in cross-chain interoperability through their Intents protocol. The platform is designed to be accessible to both blockchain enthusiasts and casual gamers by abstracting away the complexity of blockchain transactions while maintaining the benefits of on-chain verification and cross-chain asset usage.
What it does
Baultro is a multiplayer platform that enables users to compete with AI-powered vaults ("Vailts") and participate in on-chain prediction markets. The platform offers:
Battle Mode: Players engage in 1v1 duels where they attempt to break into each other's AI vaults using strategic prompts.
Raid Mode: One player creates a vault that multiple players can attempt to break into. The difficulty increases with each attempt, raising both the potential reward and the creator's earnings from collected fees.
Love Mode: Players compete to make an opponent's AI express affection, requiring different prompt strategies.
Mystery Mode: Players try to extract a secret from opposing vaults while protecting their own.
Prediction Market: Users create and bet on future events using both human knowledge and AI validation.
All transactions and funds are managed on the NEAR blockchain, with cross-chain functionality for a seamless experience.
How I built it
I developed Baultro using the following technical components:
Frontend:
- Next.js 15 with App Router for routing and server components
- React 19 for UI components
- Tailwind CSS and ShadCN UI for styling
- WebSockets for real-time updates
Backend:
- NEAR Protocol smart contracts written in Rust using NEAR SDK 4.1.1
- Supabase for database management and real-time features
- RESTful API routes for various game functionalities
Blockchain Integration:
- Two main smart contracts: one for prediction markets (
baultro-hack.testnet) and another for game modes (games.baultro-hack.testnet) - NEAR Intents protocol integration to enable cross-chain betting, allowing users to bet using assets from Ethereum, Solana, and other blockchains through standardized transaction payloads sent to the
intents.testnetcontract - Bitte wallet integration for simplified chain abstraction, providing a user-friendly interface for cross-chain transactions without requiring users to understand the underlying technical details
- Two main smart contracts: one for prediction markets (
AI Integration:
- Modular AI provider system with Gemini as the default
- Custom AI prompt evaluation logic
- Type-safe interfaces for adding additional AI providers
The smart contracts were compiled with specific flags (RUSTFLAGS='-C link-arg=-s -C target-cpu=mvp') using Rust 1.69.0 to ensure compatibility with the NEAR Virtual Machine.
Challenges I ran into
NEAR SDK Compatibility: The NEAR Virtual Machine is particular about SDK versions. After testing several combinations, I found that Rust 1.69.0 with NEAR SDK 4.1.1 provided the most reliable results. Earlier or later versions caused unexpected compilation or runtime errors.
Serialization Concerns: Once a contract is deployed, its serialization format becomes fixed. This required careful planning of data structures to avoid breaking changes. I learned that changing struct fields after deployment can result in
CompilationError(PrepareError(Deserialization))errors.Type Conversions: JavaScript strings don't automatically convert to Rust numeric types, necessitating explicit conversions when passing values between the frontend and smart contracts. I had to ensure all numeric inputs were properly parsed with
parseInt()or similar functions.Contract Annotations: I discovered significant differences between the older
#[near_bindgen]annotation style and the newer#[near(contract_state)]style. For maximum compatibility with NEAR SDK 4.1.1, I had to use the older style consistently.Cross-Contract Calls: Implementing proper promise chaining for cross-contract calls required several iterations to get right, especially ensuring the correct gas allocation and callback handling.
AI Prompt Security: Creating a balanced system where AI vaults were challenging but not impossible to break into required careful testing and iterative refinement.
Real-time State Management: Coordinating game state across multiple connected players while maintaining blockchain verification created complexity in the architecture.
Accomplishments that I'm proud of
Functional Smart Contracts: Successfully implementing and deploying two complementary smart contracts that handle complex game mechanics and prediction markets. The contracts can securely manage funds, verify game outcomes, and track cross-chain bets.
Cross-Chain Integration: Successfully implementing two complementary cross-chain technologies: 1) NEAR Intents protocol for the underlying cross-chain asset transfers, which handles the token conversions and blockchain communication, and 2) Bitte wallet integration for a simplified user experience when interacting with multiple chains. This dual-layer approach ensures both technical functionality and user accessibility.
Modular AI Integration: Building a flexible AI provider system with interfaces and adapter patterns that can easily integrate different AI services beyond the initial Gemini implementation. This includes implementing custom prompt evaluation logic specific to each game mode's requirements.
Real-time Multiplayer: Creating a responsive multiplayer experience that combines real-time gameplay with blockchain verification, including WebSocket communication for immediate updates and transaction verification.
Working Prediction Market: Implementing a functioning on-chain prediction market with proper stake handling and result verification, including support for cross-chain betting.
What I learned
NEAR Smart Contract Development: I gained practical experience with the NEAR SDK, including:
- The critical importance of using matching SDK and Rust versions (NEAR SDK 4.1.1 with Rust 1.69.0)
- How to properly handle storage with collections like
LookupMapandUnorderedMap - The necessity of initializing collections with unique key prefixes (e.g.,
b"predictions") - Managing gas costs, particularly for cross-contract calls with correct limits like
const CALLBACK_GAS: u64 = 10_000_000_000_000; - Working with fixed serialization formats that can't be changed after deployment
Rust for Blockchain: I improved my Rust programming skills specifically for blockchain contexts, including:
- Proper use of Rust type safety with explicit conversions between types
- Memory management considerations in a blockchain context
- The difference between
#[near_bindgen](older style) and#[near(contract_state)](newer style) annotations - Handling numeric constants carefully, especially with NEAR's yoctoNEAR values (1 NEAR = 10^24 yoctoNEAR)
What's next for Baultro
Audit and Mainnet Deployment:
Expanded Chain Support: Add integration with additional blockchain networks beyond the current set.
More AI Capabilities: Implement better AI evaluation mechanisms and support for additional AI providers.
Tournament System: Develop a structured competition system and more longer form games.
Mobile Interface: Create a responsive mobile interface to broaden accessibility.
Community Features: Implement social features like public chat, forums.
Built With
- bitte-agents
- near
- near-intents
- near-sdk
- nextjs
- rust
- supabase
- typescript
Log in or sign up for Devpost to join the conversation.