πΈ/transaction
Check the Prompt Guide to better prompt on Brian.
API calls to the /transaction endpoint don't automatically execute transactions onchain. The /transaction endpoint gives you back the data representing a standard transaction object! Learn more at the Transaction flow page.
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
Headers
x-brian-api-key*
String
Brian API key.
Content-Type*
application/json
Body content type.
Request Body
prompt*
String
User input prompt.
chainId
String
Chain ID of the user.
address*
String
Address that will send the transactions.
*mandatory parameters
If you don't pass the chainId in the body, the source chain will be deducted from the prompt, if available. Otherwise, it will throw an error.
View below for some real examples.
API examples
Some real examples of API calls
EVM chains
Swap tokens
Bridge tokens
Deposit on DeFi protocol
Starknet
Transfer tokens
Swap tokens
Solana
Transfer tokens
Swap tokens
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