Unifying Blockchain and AI: A Glimpse into BAI’s Revolutionary Architecture
In the constantly evolving world of technology, the boundaries of what is possible continue to expand, and at the forefront of this evolution are blockchain and artificial intelligence (AI). Today, we are thrilled to introduce you to a groundbreaking project at this exciting intersection: Blockchain AI Tools (BAI).
BAI is more than a platform — it is a revolutionary ecosystem crafted to democratize access to a suite of compact, user-friendly AI tools. Whether you need a YouTube video summarized, a tool for sparking a brainstorming session, access to the cutting-edge OpenAI API, or even image generation and large language models like GPT-4all and Vicuna, BAI streamlines and simplifies the process of harnessing these AI capabilities.
But what truly sets BAI apart is its unique participatory model. Users are not mere consumers of the AI tools but also active contributors, suggesting new tools and driving the future direction of the platform. This involvement is facilitated through BAI’s native cryptocurrency, the BAI token, which also serves as a medium of payment for the platform’s services.
Getting in detail about blockchain and AI integration
The initial feedback from our technical community introduced the concept of leveraging the BAI infrastructure to extend beyond performing basic AI tasks through BAI’s website. The idea was to enable every Smart Contract deployed on a blockchain where BAI is active to access AI tasks.
We are convinced that this integration could revolutionize the field, by bridging two of the most trending topics in IT today: Blockchain and Artificial Intelligence.
Therefore, we plan to respond to this community request in the future by implementing the following architecture:
The depicted architecture outlines the following process:
- Smart Contracts have the ability to initiate AI tasks and record them on the BAI Smart Contract.
- Agents can subsequently retrieve these AI tasks, solve them, and
- Re-store the solutions to these AI tasks back on the blockchain.
- If the BAI Smart Contract identifies that the resolved AI task was initially raised by another Smart Contract (a process we refer to as an asynchronous call), it notifies the original Smart Contract about the solution via a callback.
This structure offers a versatile solution, enabling each Smart Contract on every blockchain where BAI is implemented, to make use of external artificial intelligence tools. Consequently, this architecture deeply integrates AI tools into existing blockchain architectures.
Example of such an integration
In this section, we aim to illustrate a high-level example of how such an integration could function. Consider a scenario where a project wants to develop an AI-based game like TicTacToe, where players compete against an AI.
The game mechanics are straightforward: players make moves, and the current state of the game board is sent to a Smart Contract. This Smart Contract verifies the validity of the player’s move. If the move is valid and results in a win for the player, the contract transfers some funds to the player. However, if the move is valid but doesn’t result in a win, an AI task to “calculate” the next move is sent to the BAI Smart Contract as an asynchronous request.
An agent then solves this task by determining the AI’s optimal next move and sends the updated game board state back to the BAI Smart Contract. Recognizing this as an asynchronous task, the BAI Smart Contract triggers the callback defined in the original request on the TicTacToe contract.
The TicTacToe contract then verifies the validity of the move and, if valid, checks if the Player has won. If the Player wins, the winning funds are transferred to the Player or, depending on the game rules, retained in its treasury.
At a very abstract level, the corresponding RIDE code for the TicTacToe contract might appear as follows:
{-# STDLIB_VERSION 5 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
let BAI_CONTRACT = "<BAIs contract address>"
func isValidAndPlayerHasWon(playingField: String) = {
# Check if move is valid and if the player won already
}
@Callable(i)
func move(playingField: String) = {
if (isValidAndPlayerHasWon(playingField)) then {
# payout to player
} else {
invoke(invoke(Address(fromBase58String(BAI_CONTRACT)), "registerAITaskAsync", [ playingField, "callback" ], []))
}
}
@Callable(i)
func callback(playingField: String) = {
if (isValidAndPlayerHasWon(playingField)) then {
# payout to Player
}else{
# keep payout in treasury
}
}
This example, while abstract, provides a basic understanding of how asynchronous AI calls could function, such as defining the name of the callback (referred to as “callback” in the above example) when registering the AI task in the BAI Smart Contract.
However, it’s crucial to note that this is a preliminary concept, and the final implementation may vary slightly, although the core idea will remain intact. There are several implementation details yet to be addressed, such as whether BAI should only allow the registration of callbacks to contracts of the original AI task registrar, or if callbacks to entirely different Smart Contracts should also be possible.
In line with our user integration approach, we welcome your feedback on this matter! Your insights can help us shape the solution in a way that is both convenient and secure.