This repository contains the Python API for interacting with the BAI project's contracts on the supported blockchains. It provides a convenient way to solve tasks using the blockchain and waits for the task's solutions.
Before using this API, ensure you have Python installed on your system. To set up the API, follow these steps:
- Clone the repository to your local machine.
- Navigate to the root directory of the cloned repository.
- Install the necessary node modules by running
pip install -r requirements.txt.
To configure the API, create a .env file in the root of your project directory with the following contents:
type = 'Waves'
seed = '<Your_Seed>'
contractAddress = '<Contract Address>'
nodeURL = '<node Url>'
network = '<main or testnet>'
assetId = '<asset id>'for using the Waves network. In case of an EVM based network, the corresponding .env file should look like the following example:
type = 'evm'
contractAddress = '<the address of the main BAI contract>'
privateKey = '<your private key>'
endpoint = '<your endpoint, e.g., from alchemy, ...>'
tokenAddress = '<the contract address of the ERC20 BAI token on the network>'
chainId = '<your ChainId>'Replace the corresponding parameters with your actual settings to interact with the blockchain.
Here's a quick example to use the API to solve a task:
from BAIAPI import BAIAPI
apiInstance = BAIAPI()
try:
solution = apiInstance.solveTask('Create a picture of Kurt Gödel', 'dalle')
print('Solution: ', solution)
except:
print('Error: ', Exception)This script initializes the API, sends a task to the blockchain, and logs the solution once it's ready.
Sends a task to the blockchain for solving and returns the solution.
task: The task description or objective.taskType: The type of task to register on the blockchain.
This is the main API module that abstracts the WavesConnection to interact with the Waves blockchain.
Handles direct interactions with the Waves blockchain, such as sending tasks, retrieving task prices, and waiting for task solutions.
- BAI Token: 2fdzyHvXGCqaz1XA8m9fodemmP9giVBcpe4Jq9F63oFL
- BAI Tasks: 3PMu8gHthb5uQgpqDvUQ3GZGdovPvypoMQ5
- BAI Token: 0x10Da043D0B46e43B53B74a88AC60CCC28e2AFDf8
- BAI Tasks: 0xbEfd1Ac0eF34136f3F4E2baCc878bea99b45951F
- BAI Token: 0x6a27CD26a373530835B9fE7aC472B3e080070F64
- BAI Tasks: 0xC9C19f5ac2433b4B96d8AaAca6890598801f626F
chatgpt, orca, gemini, llama3
dalle, stable-diffusion
youtube
discussion
brainstorm
If you'd like to contribute to the project, please fork the repository and use a feature branch. Pull requests are warmly welcome.
The code in this project is licensed under MIT license.