Inspiration While interacting with large language models, I noticed that every request and response is measured in tokens. That gave me the idea to bring this concept on-chain: create a free zone of usage and then a paywall when users go beyond a certain threshold.

What it does tokenXllm provides a free daily quota of AI usage on Starknet, and once that limit is reached, users seamlessly pay with a custom ERC-20 token. This ensures fair access, transparent accounting, and a decentralized way to meter AI consumption.

How we built it ERC-20 Token (AIC) in Cairo 1 to handle payments.

UsageManager contract to track per-user usage, enforce the free tier, and process paid units. Scarb + Starknet Foundry for compiling, testing, and deploying on Starknet Sepolia. asdf toolchain for consistent versions of Rust, Python, and Node. Designed a future gateway off-chain to listen to UsageAuthorized events and synchronize access to AI services.

Challenges we ran into Making the free tier truly feel free despite Starknet gas costs (solution: explore relayers or paymasters). Handling decimals and pricing math accurately when mixing token units with AI usage units. Ensuring off-chain gateway trust by aligning strictly with on-chain events. Overcoming the learning curve of Cairo 1 while building production-ready contracts.

Accomplishments that we're proud of Built a working ERC-20 token + usage manager system from scratch in Cairo 1. Established a clear free/premium model for AI consumption on-chain. Created a repo scaffold with contracts, tests, and deploy scripts, making it easy for others to build on top.

What we learned How to design usage-based token economics that feel intuitive to both users and developers. The importance of epochs as a mechanism for renewable quotas. How to integrate modern tooling (Scarb, Starknet Foundry, asdf) into a smooth developer workflow. That UX and security are equally important when bridging on-chain logic with off-chain AI services.

What's next for tokenXllm Add relayer/paymaster support so the free tier costs zero gas. Launch NFT/Pass tiers for premium benefits (higher quota, lower rates). Integrate the off-chain gateway to connect directly with AI models. Build a frontend dashboard showing quota usage, costs, and history. Explore partnerships with AI providers to tokenize and monetize usage in real time.

Built With

  • asdf
  • scarb
  • starknet-foundry
Share this project:

Updates