πŸ’Έ/transaction

Generate transaction(s) from a prompt.

POST https://api.brianknows.org/api/v0/agent/transaction

This allows you to send a prompt to Brian and return a transaction calldata, ready to be executed onchain, and multiple transaction info parameters.

Some of the supported actions include:

  • swap

  • bridge

  • transfer

  • deposit and withdraw from DeFi protocols

  • ENS domain registration

Check the next page for a comprehensive overview of actions and chains supported.

Headers

Name
Type
Description

x-brian-api-key*

String

Brian API key.

Content-Type*

application/json

Body content type.

Request Body

Name
Type
Description

prompt*

String

User input prompt.

chainId

String

Chain ID of the user.

address*

String

Address that will send the transactions.

*mandatory parameters

View below for some real examples.

API examples

Some real examples of API calls

EVM chains

Swap tokens

Response

The steps array can contain a list of possible swap routes that the user can choose from. In some cases, it could return just one step.

Bridge tokens

Response

The steps array can contain a list of possible swap routes that the user can choose from. In some cases, it could return just one step.

Deposit on DeFi protocol

Response


Starknet

Transfer tokens

Response

Swap tokens

Response

Solana

Transfer tokens

Response

Swap tokens

Response

Allowance and Approval management

For EVMs and Starknet, the steps array will contain an approve transaction as the first position when needed according to the transaction involved.

It first checks the existing allowance and returns a transaction approving the exact amount needed.

For example, if the transaction involves a native token as the input token, the steps array will not contain the approve transaction. If the transaction involves an ERC20 token as the input token and the existing allowance covers the amount to spend, the steps array will not contain the approve transaction. Finally, suppose the transaction involves an ERC20 token as the input token and the existing allowance doesn't cover the amount to spend. In that case, the steps array will contain the approve transaction in the first position.

Here is an example of a USDC swap:

Last updated