Skip to content

guidanoli/thinkchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThinkChain

ThinkChain is an on-chain service that enables smart contracts to perform verifiable large language model (LLM) inference. The service provides access to a variety of popular LLMs, such as DeepSeek-R1, DeepScaleR, Qwen2.5 and SmolLM2. A simple Solidity interface makes it easy for smart contracts to construct prompts and decode replies entirely on-chain. Completion requests are charged in Ether.

Client contracts send completion requests to the Completer contract, which issues tasks to EigenLayer operators. Operators run the selected inference model inside a Cartesi Machine to guarantee determinism. Results are then signed by operators, and an aggregated signature is submitted to a solver. Once the solver submits the signed result on-chain, the Completer forwards it to a Callback contract, designated by the Client.

ThinkChain is suitable for smart contracts that would benefit from on-chain access to LLMs. Examples of use cases include AI agents, AI-assisted decision making, data analysis, and content generation. Client contracts can propagate the cost of using the service to their users, and even charge extra for their services.

Features

  • Access to a wide variety of LLMs
  • Simple Solidity interface
  • Configurable inference options
  • Fast finality
  • Accepts payments in Ether

Overview

For a quick overview and demo of the project, you can watch the presentation submitted for Cartesi X EigenLayer Experimentation Week:

ThinkChain Quick Demo

Getting Started

First, please make sure your machine contains all the necessary dependencies. Then, clone this repository and its submodules recursively.

git clone --recurse-submodules https://github.com/guidanoli/thinkchain.git

In order to run ThinkChain locally, you first need to start up a devnet.

cartesi-coprocessor start-devnet

Once the devnet is up, you may publish the machine.

cartesi-coprocessor publish --network devnet

Then, you may deploy the contracts.

make deploy

Once the contracts are deployed, you can interactively request a completion.

make request

Documentation

You can learn more about ThinkChain smart contracts here.

Web Frontend

This repository also includes a proof-of-concept chat app that uses ThinkChain. You can run it locally and interact with it through a web front-end.

make run-frontend-dev

In order to interact in the frontend you will need to import a wallet with funds, you could import the wallet with the private key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 in Metamask browser extension.

Related projects

Authors

License

ThinkChain is licensed under GPL-3.0.