# Solana Object

## Solana Object Documentation

The `Solana` class encapsulates various methods for interacting with Solana blockchain transactions and accounts. It provides functionality for submitting transactions, transferring tokens, setting compute budgets, and estimating priority fees. This class extends the `Subscribable` class, making it possible to watch and subscribe to address events.

### Methods

#### watchAddress

**Description** Watches a specified address for transactions and invokes a callback when an event occurs.

**Signature**

```typescript
public async watchAddress(
  address: string,
  callback: (event: RoboqoTransaction) => void
): Promise<SubscriptionResult>
```

**Parameters**

* `address` (`string`): The address to watch for transactions.
* `callback` (`(event: RoboqoTransaction) => void`): The callback function to invoke when a transaction event is detected.

**Returns**

* `Promise<SubscriptionResult>`: The result of the subscription operation.

***

#### transferTokens

**Description** Transfers tokens to a specified public key.

**Signature**

```typescript
public async transferTokens({
  toPublicKey,
  mintPublicKey,
  amount,
}: {
  toPublicKey: PublicKeyOrString;
  mintPublicKey: PublicKeyOrString;
  amount: number | string;
}): Promise<Transaction>
```

**Parameters**

* `toPublicKey` (`PublicKeyOrString`): The recipient's public key.
* `mintPublicKey` (`PublicKeyOrString`): The mint address of the token.
* `amount` (`number | string`): The amount of tokens to transfer.

**Returns**

* `Promise<Transaction>`: The deserialized transaction object.

***

#### transferSol

**Description** Transfers SOL to a specified public key.

**Signature**

```typescript
public async transferSol({
  toPublicKey,
  amountLamports,
}: {
  toPublicKey: PublicKeyOrString;
  amountLamports: number | string;
}): Promise<Transaction>
```

**Parameters**

* `toPublicKey` (`PublicKeyOrString`): The recipient's public key.
* `amountLamports` (`number | string`): The amount in lamports to transfer.

**Returns**

* `Promise<Transaction>`: The deserialized transaction object.

***

#### submitTransaction

**Description** Submits a single transaction to the Solana blockchain.

**Signature**

```typescript
public async submitTransaction(
  transaction: Transaction | VersionedTransaction,
  options?: { skipPreFlight?: boolean }
): Promise<SolanaTransaction>
```

**Parameters**

* `transaction` (`Transaction | VersionedTransaction`): The transaction to submit.
* `options` (`{ skipPreFlight?: boolean }`): Optional. Whether to skip the pre-flight check.

**Returns**

* `Promise<SolanaTransaction>`: An object containing the transaction signature.

***

#### submitTransactions

**Description** Submits multiple transactions to the Solana blockchain.

**Signature**

```typescript
public async submitTransactions(
  request: SubmitTransactionsRequest
): Promise<SolanaBundle>
```

**Parameters**

* `request` (`SubmitTransactionsRequest`): An object containing:
  * `transactions` (`(Transaction | VersionedTransaction)[]`): Array of transactions to submit.
  * `skipPreFlight` (`boolean`): Optional. Whether to skip the pre-flight check.

**Returns**

* `Promise<SolanaBundle>`: The result of the RPC call containing transaction signatures.

***

#### setComputeBudget

**Description** Sets a custom compute budget for a transaction.

**Signature**

```typescript
public async setComputeBudget(
  tx: Transaction | VersionedTransaction,
  microLamports: number
): Promise<Transaction>
```

**Parameters**

* `tx` (`Transaction | VersionedTransaction`): The transaction to modify.
* `microLamports` (`number`): The compute budget in micro-lamports.

**Returns**

* `Promise<Transaction>`: The deserialized transaction with the updated compute budget.

***

#### getPriorityFeeEstimates

**Description** Fetches priority fee estimates for transactions based on historical data.

**Signature**

```typescript
public async getPriorityFeeEstimates(
  request?: PriorityFeeEstimatesRequest
): Promise<PriorityFeeEstimates>
```

**Parameters**

* `request` (`PriorityFeeEstimatesRequest`): Optional. An object containing:
  * `account` (`string`): Optional. The account to estimate fees for.
  * `lastNBlocks` (`number`): Optional. The number of blocks to consider.

**Returns**

* `Promise<PriorityFeeEstimates>`: The estimated priority fee details for transactions.

***

#### getPriorityFeeEstimate

**Description** Estimates the priority fee for a transaction based on the specified priority level.

**Signature**

```typescript
public async getPriorityFeeEstimate(
  request: PriorityFeeEstimateRequest
): Promise<any>
```

**Parameters**

* `request` (`PriorityFeeEstimateRequest`): An object containing:
  * `priorityLevel` (`string`): The priority level (e.g., "Low", "Medium", "High").
  * `account` (`string`): Optional. The account to estimate fees for.
  * `lastNBlocks` (`number`): Optional. The number of blocks to consider.

**Returns**

* `Promise<any>`: The estimated priority fee.

***

#### addPriorityFee

**Description** Adds a specified priority fee to a transaction.

**Signature**

```typescript
public async addPriorityFee(
  transaction: Transaction | VersionedTransaction,
  microLamports: number
): Promise<Transaction>
```

**Parameters**

* `transaction` (`Transaction | VersionedTransaction`): The transaction to modify.
* `microLamports` (`number`): The priority fee in micro-lamports.

**Returns**

* `Promise<Transaction>`: The deserialized transaction with the added priority fee.

***

#### addPriorityFeeWithEstimate

**Description** Adds an estimated priority fee to a transaction based on the specified priority level.

**Signature**

```typescript
public async addPriorityFeeWithEstimate(
  transaction: Transaction | VersionedTransaction,
  priorityLevel?: string
): Promise<Transaction>
```

**Parameters**

* `transaction` (`Transaction | VersionedTransaction`): The transaction to modify.
* `priorityLevel` (`string`): Optional. The priority level (default is "Medium").

**Returns**

* `Promise<Transaction>`: The deserialized transaction with the estimated priority fee added.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.roboqo.com/global-objects/images-and-media.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
