# Solana Provider

The Tomo Telegram SDK provides a Solana Provider for querying and sending SOL and SPL tokens.&#x20;

```typescript
// get provider 
const sol = window.tomo_sol;
```

## Connect with the Wallet[​](https://docs.uxuy.com/uxuy-connect/guide/#isconnected) <a href="#isconnected" id="isconnected"></a>

Before using the provider, the user needs to log in to the wallet through the modal by following the method:

```typescript
// connect wallet
await sol?.connectWallet();
```

## Query Methods

Solana providers support two query methods:

* `getAddress`
* `getBalance`

<pre class="language-typescript"><code class="lang-typescript"><strong>const address = sol.getAddress();
</strong>const balance = await sol.getBalance(address);
</code></pre>

## Signing Methods

In Solana providers, we provide four signing methods:

* `signMessage`
* `signTransaction`
* `signTransactions`
* `signTokenTransaction`

### Sign message

`signMessage` the method will create an offchain signature for one message and return the signed transaction in hex.

```typescript
 const response = await sol.signMessage(signMsg);
```

To verify the signature, you need to add the header "\xffsolana offchain" before the \`signMsg\`

### SOL transfer transaction

`signTransaction` is typically used to send SOL to another address and return the signed transaction. You can also use `signTransactions` it to pass an array of transactions for signing.

```typescript
const response = await sol.signTransaction({
  from: 8y9wmwVhban5Mrp8j68fQv1Kceeifeowt5Yw1DjwXoxk,
  to: 646rZ228LDcYecNvoBGNysJ9pGLc7gBeTrnSgZ476rBp,
  value: 0.01,
});
```

### SPL token transaction

and `signTokenTransaction` supports signing transactions for sending SPL tokens. You need to provide a mint address for this transaction.

```typescript
const response = await sol.signTokenTransaction({
  from: '8y9wmwVhban5Mrp8j68fQv1Kceeifeowt5Yw1DjwXoxk',
  to: '646rZ228LDcYecNvoBGNysJ9pGLc7gBeTrnSgZ476rBp',
  value: val,
  chainId: 501,
  contract: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
});
```

## Sending Methods

After signing transactions, you can use `sendTransaction` it to send the transaction. The return value is the transaction hash:

```typescript
const res = await sol.sendTransaction(response);
```


---

# 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://docs.tomo.inc/tomo-sdk/tomo-telegram-sdk/wallet-provider/solana-provider.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.
