For the complete documentation index, see llms.txt. This page is also available as Markdown.

Solana

The transactions returned by the Brian API are compatible with the most common development tools, such as Solana-Web3.js.

The transaction contained in the API response is a serialized transaction. The steps to be taken are:

  1. deserialize and sign the transaction

  2. execute the transaction

Deserialize, sign and execute the transaction(s)

Access the transaction object from the Brian API response (using the Brian ts SDK):


const brian = new BrianSDK(options);

const request = await brian.transact({
  prompt: "swap 1 sol for USDC on solana",
  address: "53unSgGWqEWANcPYRF35B2Bgf8BkszUtcccKiXwGGLyr",
});
console.log("transaction result:", request);

// Create an empty array to store transactions
const txArray = [];

// Loop through the requests and their steps
for (const req of request) {
  for (const step of req.data.steps) {
    // Push the step's data into the txArray
    txArray.push(step.data);
  }
}

console.log("Transaction Array:", txArray);

Now, you can deserialize, sign, and execute the transaction(s)

Last updated