Skip to content

BAIToken/python-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BAI Project Blockchain API

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.

Installation

Before using this API, ensure you have Python installed on your system. To set up the API, follow these steps:

  1. Clone the repository to your local machine.
  2. Navigate to the root directory of the cloned repository.
  3. Install the necessary node modules by running pip install -r requirements.txt.

Configuration

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.

Usage

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.

API Reference

solveTask(task, taskType)

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.

Modules

BAIAPI.py

This is the main API module that abstracts the WavesConnection to interact with the Waves blockchain.

wavesConnection.py

Handles direct interactions with the Waves blockchain, such as sending tasks, retrieving task prices, and waiting for task solutions.

Contract Addresses

Waves mainnet:

BNB mainnet:

Base Mainnet:

Available Task Types

Simple Text Request:

chatgpt, orca, gemini, llama3

Image Generation:

dalle, stable-diffusion

Video Summarize:

youtube

Discussion:

discussion

Brainstorming:

brainstorm

Fee and extra details:

Contributing

If you'd like to contribute to the project, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Licensing

The code in this project is licensed under MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages