đ¸/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 transaction object (from, to, value, data).
Generate transaction(s) from a prompt.
POST
https://api.brianknows.org/api/v0/agent/transaction
Allows you to send a prompt to Brian and generate all the needed parameters to send that given transaction(s).
The currently available actions are:
swap
bridge
crosschain swap
transfer
approve
wrap and unwrap native token
deposit and withdraw from defi protocols
borrow and repay from AAVE v3
AAVE v3 check actions (loan-to-value, health rate, liquidation threshold, borrowed amount, borrowable amount)
ENS domain registration
ENS domain renewal
ENS checks actions (availability, expiration, forward and reverse resolution and check registration and renewal costs)
Headers
Request Body
*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.
{
"result": [
{
"solver": "",
"action": "",
"type": "",
"data": {
"description": "",
"steps": [
{
"chainId": ,
"blockNumber": ,
"from": "",
"to": "",
"gasLimit": "",
"data": "",
"value": "",
"protocol": {
"key": "",
"name": "",
"logoURI": ""
}
}
],
"gasCostUSD": "",
"fromChainId": ,
"fromAmountUSD": ,
"fromAmount": "",
"fromToken": {
"address": "",
"chainId": ,
"symbol": "",
"decimals": ,
"name": "",
"coinKey": "",
"logoURI": "",
"priceUSD": ""
},
"fromAddress": "",
"toChainId": ,
"toAmountUSD": ,
"toAmount": "",
"toAmountMin": "",
"toToken": {
"address": "",
"chainId": ,
"symbol": "",
"decimals": ,
"name": "",
"coinKey": "",
"logoURI": "",
"priceUSD": ""
},
"toAddress": "",
"receiver": "",
"protocol": {
"key": "",
"name": "",
"logoURI": ""
}
}
"extractedParams": {
"action": "",
"chain": "",
"token1": "",
"token2": "",
"address": "",
"amount": ""
},
"conversationHistory": [
{
"sender": "",
"content": ""
},
{
"sender": "",
"content": ""
}
]
}
]
}
{
"error": ",
"extractedParams": [
{
"action": "",
"chain": "",
"token1": "",
"token2": "",
"address": "",
"amount": "",
....
}
],
"conversationHistory": [
{
"sender": "",
"content": ""
},
{
"sender": "",
"content": ""
}
]
}
{
"error": "internal server error."
}
API examples
Here are some examples of calling the APIs described above.
Transfer native tokens
curl -XPOST "https://api.brianknows.org/api/v0/agent/transaction" -H "Content-Type: application/json" -H "x-brian-api-key: API_KEY" -d '{
"prompt": "I want to transfer 10 MATIC to 0x9319b31838bba444CCeAeD025153a48AD6377471 on Polygon",
"address": "0x9319b31838bba444CCeAeD025153a48AD6377471"
}'
Response
{
"result": [
{
"solver": "Brian",
"action": "transfer",
"type": "write",
"data": {
"description": "You are about to send 10.000000 MATIC ($5.15) to 0x9319...7471 on Polygon.",
"steps": [
{
"chainId": 137,
"blockNumber": 60029917,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"value": "10000000000000000000",
"gasLimit": "21000"
}
],
"fromChainId": 137,
"fromAmount": "10000000000000000000",
"fromToken": {
"address": "0x0000000000000000000000000000000000000000",
"chainId": 137,
"symbol": "MATIC",
"decimals": 18,
"name": "MATIC",
"coinKey": "MATIC",
"logoURI": "https://static.debank.com/image/matic_token/logo_url/matic/6f5a6b6f0732a7a235131bd7804d357c.png",
"priceUSD": "0.5146"
},
"fromAddress": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"toChainId": 137,
"toAmount": "10000000000000000000",
"toAmountMin": "10000000000000000000",
"toToken": {
"address": "0x0000000000000000000000000000000000000000",
"chainId": 137,
"symbol": "MATIC",
"decimals": 18,
"name": "MATIC",
"coinKey": "MATIC",
"logoURI": "https://static.debank.com/image/matic_token/logo_url/matic/6f5a6b6f0732a7a235131bd7804d357c.png",
"priceUSD": "0.5146"
},
"toAddress": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"receiver": "0x9319b31838bba444CCeAeD025153a48AD6377471"
}
}
]
}
Transfer ERC-20 tokens
curl -XPOST "https://api.brianknows.org/api/v0/agent/transaction" -H "Content-Type: application/json" -H "x-brian-api-key: API_KEY" -d '{"prompt": "I want to transfer 10 USDC to 0x9319b31838bba444CCeAeD025153a48AD6377471 on Polygon",
"address": "0x9319b31838bba444CCeAeD025153a48AD6377471"
}'
Response
{
"result": [
{
"solver": "Brian",
"action": "transfer",
"type": "write",
"data": {
"description": "You are about to send 10.000000 DAI ($10.00) to 0x9319...7471 on Polygon.",
"steps": [
{
"chainId": 137,
"blockNumber": 60030000,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
"value": "0",
"data": "0xa9059cbb0000000000000000000000009319b31838bba444cceaed025153a48ad63774710000000000000000000000000000000000000000000000008ac7230489e80000",
"gasLimit": "100000"
}
],
"fromChainId": 137,
"fromAmount": "10000000000000000000",
"fromToken": {
"address": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
"chainId": 137,
"symbol": "DAI",
"decimals": 18,
"name": "(PoS) DAI Stablecoin",
"coinKey": "DAI",
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeAC495271d0F/logo.png",
"priceUSD": "1.0001"
},
"fromAddress": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"toChainId": 137,
"toAmount": "10000000000000000000",
"toAmountMin": "10000000000000000000",
"toToken": {
"address": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
"chainId": 137,
"symbol": "DAI",
"decimals": 18,
"name": "(PoS) DAI Stablecoin",
"coinKey": "DAI",
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeAC495271d0F/logo.png",
"priceUSD": "1.0001"
},
"toAddress": "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
"receiver": "0x9319b31838bba444CCeAeD025153a48AD6377471"
}
}
]
}
Swap tokens
curl -XPOST "https://api.brianknows.org/api/v0/agent/transaction" -d '{"prompt": "I want to swap 10 USDC for ETH on base", "address": "0x9319b31838bba444CCeAeD025153a48AD6377471"}' -H "Content-Type: application/json" -H "x-brian-api-key: API_KEY"
Response
{
"result": [
{
"solver": "Enso",
"action": "swap",
"type": "write",
"data": {
"description": "You are about to swap 10.000000 USDC($10.00) for 0.002988 ETH ($9.96) on Base using Enso solver. The address receiver is 0x9319...7471.",
"steps": [
{
"chainId": 8453,
"blockNumber": 17822776,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"gasLimit": "80000",
"data": "0x095ea7b300000000000000000000000080eba3855878739f4710233a8a19d89bdd2ffb8e0000000000000000000000000000000000000000000000000000000000989680",
"value": "0"
},
{
"chainId": 8453,
"blockNumber": 17822776,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0x80EbA3855878739F4710233A8a19d89Bdd2ffB8E",
"gasLimit": "453028",
"data": "0xb35d7e73000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000989680000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000008a9059cbb010001ffffffffff833589fcd6edb6e08f4c7c32d4f71b54bda02913095ea7b3010203ffffffffff833589fcd6edb6e08f4c7c32d4f71b54bda0291319198595a30485ffffffff85def1c0ded9bec7f1a1670819833240f027b25eff9bd3b227018504ffffffff056675a323dedb77822fcf39eaa9d682f6abe72555ddcd52200105ffffffffff057e7d64d987cab6eed08a191c4c2459daf2f8ed0b19198595a30586ffffffffff9319b31838bba444cceaed025153a48ad63774716e7a43a3010507ffffffff057e7d64d987cab6eed08a191c4c2459daf2f8ed0b241c59120105ffffffffffff7e7d64d987cab6eed08a191c4c2459daf2f8ed0b000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000000000000000000000000000000000aa00000000000000000000000000000000000000000000000000000000000000ac00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000129b480ad625bcd1a5c3a1c10d708114726fa467000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000986f70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000828415565b0000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000986f70000000000000000000000000000000000000000000000000000a4c14a690bf9d00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000004600000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913000000000000000000000000420000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000340000000000000000000000000000000000000000000000000000000000000034000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000986f70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000012556e69737761705633000000000000000000000000000000000000000000000000000000000000000000000000986f70000000000000000000000000000000000000000000000000000a500a6d210dd7000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000002626664c2603336e57b271c5c0b26f421741e481000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000042833589fcd6edb6e08f4c7c32d4f71b54bda0291300006450c5725949a6f0c72e6c4a641f24049a917db0cb0001f442000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000400000000000000000000000004200000000000000000000000000000000000006ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000000003f5c6904e3a000000000000000000000000ad01c20d5886137e056775af56915de824c8fce50000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000000000000869584cd000000000000000000000000100000000000000000000000000000000000001100000000000000000000000000000000000000005b210060dff63345919e860400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000a4c3321aed839",
"value": "0"
}
],
"gasCostUSD": "",
"fromChainId": 8453,
"fromAmountUSD": "10",
"fromAmount": "10000000",
"fromToken": {
"address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"chainId": 8453,
"symbol": "USDC",
"decimals": 6,
"name": "USD Coin",
"coinKey": "USDC",
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
"priceUSD": "1"
},
"fromAddress": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"toChainId": 8453,
"toAmountUSD": "9.957563936252797",
"toAmount": "2988177586862245",
"toAmountMin": "2988177586862245",
"toToken": {
"address": "0x0000000000000000000000000000000000000000",
"chainId": 8453,
"symbol": "ETH",
"decimals": 18,
"name": "ETH",
"coinKey": "ETH",
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png",
"priceUSD": "3332.32"
},
"toAddress": "0x80EbA3855878739F4710233A8a19d89Bdd2ffB8E",
"receiver": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"protocol": {
"key": "enso",
"name": "enso",
"logoURI": ""
}
}
}
]
}
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
curl -XPOST "https://api.brianknows.org/api/v0/agent/transaction" -d '{"prompt": "I want to bridge 10 USDC from Ethereum to Arbitrum", "address": "0x9319b31838bba444CCeAeD025153a48AD6377471"}' -H "Content-Type: application/json" -H "x-brian-api-key: API_KEY"
Response
{
"result": [
{
"solver": "Bungee",
"action": "bridge",
"type": "write",
"data": {
"description": "You are about to bridge 10.000000 USDC for 9.975330 USDC ($10.00) from Ethereum to Arbitrum one using Bungee solver. The address receiver is 0x9319...7471.",
"steps": [
{
"chainId": 1,
"blockNumber": 20427034,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"gasLimit": "80000",
"data": "0x095ea7b30000000000000000000000003a23f943181408eac424116af7b7790c94cb97a50000000000000000000000000000000000000000000000000000000000989680",
"value": "0"
},
{
"chainId": 1,
"blockNumber": 20427034,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0x3a23F943181408EAC424116Af7b7790c94Cb97a5",
"gasLimit": "500000",
"data": "0x000001ad792ebcb90000000000000000000000000000000000000000000000000000000000989680000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000605c00000000000000000000000000000000000000000000000000000000000009ea00000000000000000000000000000000000000000000000000000000000000020000000000000000000000009319b31838bba444cceaed025153a48ad63774710000000000000000000000009319b31838bba444cceaed025153a48ad63774710000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000983624000000000000000000000000000000000000000000000000000000000000a4b100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000066aa44c70000000000000000000000000000000000000000000000000000000066aa98cdd00dfeeddeadbeef765753be7f7a64d5509974b0d678e1e3149b02f4",
"value": "0x00"
}
],
"gasCostUSD": "",
"fromChainId": 1,
"fromAmountUSD": "10",
"fromAmount": "10000000",
"fromToken": {
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"chainId": 1,
"symbol": "USDC",
"decimals": 6,
"name": "USD Coin",
"coinKey": "USDC",
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
"priceUSD": "1"
},
"fromAddress": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"toChainId": 42161,
"toAmountUSD": "9.97533",
"toAmount": "9975332",
"toAmountMin": "9975332",
"toToken": {
"address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"chainId": 42161,
"symbol": "USDC",
"decimals": 6,
"name": "USD Coin",
"coinKey": "USDC",
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
"priceUSD": "1"
},
"toAddress": "0x3a23F943181408EAC424116Af7b7790c94Cb97a5",
"receiver": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"protocol": {
"key": "across",
"name": "Across",
"logoURI": "https://miro.medium.com/max/800/1*PN_F5yW4VMBgs_xX-fsyzQ.png"
}
}
}
]
}
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.
Register an ENS domain
curl -XPOST "https://api.brianknows.org/api/v0/agent/transaction" -d '{"prompt": "Register limonee.eth for 2 years and set is as my primary domain name", "address": "0xA9bC8A58B39935BA3D8D1Ce4b0d3383153F184E1"}' -H "Content-Type: application/json" -H "x-brian-api-key: API_KEY"
Response
{
"result": [
{
"solver": "Brian",
"action": "ENS Registration",
"type": "write",
"data": {
"description": "You are about to register the ENS domain \"limonee.eth\" for 24 months and setting it as your primary name for your address 0x9319...7471. The ENS registration cost is 0.0030 ETH ($10.019668699711644). The operation is a two steps process. The first transaction will commit the registration and the second one will register the domain. Wait at least 1 minute for executing the second transaction.",
"steps": [
{
"chainId": 1,
"blockNumber": 20427038,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0x253553366Da8546fC250F225fe3d25d0C782303b",
"value": 0,
"data": "0xf14fcbc880ce9121405f72b0ed88260be612d55e4e8d8579a63506a0fb733975e61b0198",
"gasLimit": "200000"
},
{
"chainId": 1,
"blockNumber": 20427038,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0x253553366Da8546fC250F225fe3d25d0C782303b",
"value": "3308191081120538",
"data": "0x74694a2b00000000000000000000000000000000000000000000000000000000000001000000000000000000000000009319b31838bba444cceaed025153a48ad63774710000000000000000000000000000000000000000000000000000000003c2670051ba771fcc67b8022466825620b13e9a73b2235a008be4773b4239dc9fe54629000000000000000000000000231b0ee14048e9dccd1d247744d114a4eb5e8e6300000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076c696d6f6e6565000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a48b95dd7172d85bc1f8e5f2cbeea233446b3b3fceb8614d6e873ed54de9de3621a21f302c000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000149319b31838bba444cceaed025153a48ad637747100000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "200000"
}
],
"fromChainId": 1,
"fromAmount": 0,
"fromToken": {
"address": "0x0000000000000000000000000000000000000000",
"chainId": 1,
"symbol": "ETH",
"decimals": 18,
"name": "ETH",
"coinKey": "ETH",
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png",
"priceUSD": "3331.62"
},
"fromAddress": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"toChainId": 1,
"toAmount": 0,
"toAmountMin": 0,
"toToken": {
"address": "0x0000000000000000000000000000000000000000",
"chainId": 1,
"symbol": "ETH",
"decimals": 18,
"name": "ETH",
"coinKey": "ETH",
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png",
"priceUSD": "3331.62"
},
"toAddress": "0x253553366Da8546fC250F225fe3d25d0C782303b"
}
}
]
}
Deposit on DeFi protocol
curl -XPOST "https://api.brianknows.org/api/v0/agent/transaction" -d '{"prompt": "deposit 100 usdc to aave protocol on Ethereum", "address": "0xA9bC8A58B39935BA3D8D1Ce4b0d3383153F184E1"}' -H "Content-Type: application/json" -H "x-brian-api-key: API_KEY"
Response
{
"result": [
{
"solver": "Enso",
"action": "deposit",
"type": "write",
"data": {
"description": "You are about to deposit 100.000000 USDC ($100.00) into aave-v3 protocol, obtaining 99.900000 AETHUSDC on Ethereum. The address receiver is: 0x9319...7471.",
"steps": [
{
"chainId": 1,
"blockNumber": 20427040,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"gasLimit": "80000",
"data": "0x095ea7b300000000000000000000000080eba3855878739f4710233a8a19d89bdd2ffb8e0000000000000000000000000000000000000000000000000000000005f5e100",
"value": "0"
},
{
"chainId": 1,
"blockNumber": 20427040,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0x80EbA3855878739F4710233A8a19d89Bdd2ffB8E",
"gasLimit": "358072",
"data": "0xb35d7e73000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000005f5e100000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000009a9059cbb010001ffffffffffa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48095ea7b3010203ffffffffffa0b86991c6218b36c1d19d4a2e9eb0ce3606eb4870a082310104ffffffffff0298c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5ce8eda9df0105030406ffffff87870bca3f3fd6335c3f4ce8392d69350b4fa4e270a082310104ffffffffff0498c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5cb67d77c5010402ffffffff04ca99eaa38e8f37a168214a3a57c9a45a58563ed5a9059cbb010704ffffffffff98c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5c6e7a43a3010408ffffffff047e7d64d987cab6eed08a191c4c2459daf2f8ed0b241c59120104ffffffffffff7e7d64d987cab6eed08a191c4c2459daf2f8ed0b00000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000129b480ad625bcd1a5c3a1c10d708114726fa467000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000087870bca3f3fd6335c3f4ce8392d69350b4fa4e200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000005f45a6000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007d585b0e27bbb3d981b7757115ec11f47c4769940000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000009319b31838bba444cceaed025153a48ad637747100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000005c69f58",
"value": "0"
}
],
"gasCostUSD": "",
"fromChainId": 1,
"fromAmountUSD": "100",
"fromAmount": "100000000",
"fromToken": {
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"chainId": 1,
"symbol": "USDC",
"decimals": 6,
"name": "USD Coin",
"coinKey": "USDC",
"logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
"priceUSD": "1"
},
"fromAddress": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"toChainId": 1,
"toAmountUSD": "99.9",
"toAmount": "100000000",
"toAmountMin": "100000000",
"toToken": {
"address": "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c",
"chainId": 1,
"symbol": "aEthUSDC",
"decimals": 6,
"name": "Aave Ethereum USDC",
"coinKey": "aEthUSDC",
"logoURI": "https://static.debank.com/image/eth_token/logo_url/0x98c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5c/d1e0d14800c1e4657fb8c25e0f073cf0.png",
"priceUSD": "1"
},
"toAddress": "0x80EbA3855878739F4710233A8a19d89Bdd2ffB8E",
"receiver": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"protocol": {
"key": "aave-v3",
"name": "aave-v3",
"logoURI": ""
}
}
}
]
}
Allowance and Approval management
The steps
array will contain an approve transaction as the first position when needed according to the transaction involved.
It checks the existing allowance first 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, if the transaction involves an ERC20 token as the input token and the existing allowance doesn't cover the amount to spend, the steps array will contain the approve transaction
Here is an example of an USDC swap:
...
"steps": [
// Approve transaction first
{
"chainId": 1,
"blockNumber": 20427040,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"gasLimit": "80000",
"data": "0x095ea7b300000000000000000000000080eba3855878739f4710233a8a19d89bdd2ffb8e0000000000000000000000000000000000000000000000000000000005f5e100",
"value": "0"
},
// Swap transaction in second place
{
"chainId": 1,
"blockNumber": 20427040,
"from": "0x9319b31838bba444CCeAeD025153a48AD6377471",
"to": "0x80EbA3855878739F4710233A8a19d89Bdd2ffB8E",
"gasLimit": "358072",
"data": "0xb35d7e73000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000005f5e100000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000009a9059cbb010001ffffffffffa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48095ea7b3010203ffffffffffa0b86991c6218b36c1d19d4a2e9eb0ce3606eb4870a082310104ffffffffff0298c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5ce8eda9df0105030406ffffff87870bca3f3fd6335c3f4ce8392d69350b4fa4e270a082310104ffffffffff0498c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5cb67d77c5010402ffffffff04ca99eaa38e8f37a168214a3a57c9a45a58563ed5a9059cbb010704ffffffffff98c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5c6e7a43a3010408ffffffff047e7d64d987cab6eed08a191c4c2459daf2f8ed0b241c59120104ffffffffffff7e7d64d987cab6eed08a191c4c2459daf2f8ed0b00000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000129b480ad625bcd1a5c3a1c10d708114726fa467000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000087870bca3f3fd6335c3f4ce8392d69350b4fa4e200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000005f45a6000000000000000000000000000000000000000000000000000000000000000200000000000000000000000007d585b0e27bbb3d981b7757115ec11f47c4769940000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000009319b31838bba444cceaed025153a48ad637747100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000005c69f58",
"value": "0"
}
],
...
Last updated