# Sui Provider (Beta)

The Tomo Telegram SDK provides the SUI provider for getting addresses, signing, and sending transactions.&#x20;

```typescript
// get provider 
const sui= window.tomo_sui;
```

## 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 sui?.connectWallet();
```

## Query Address

You can get the address of the user by one cal

```typescript
const address = sui.getAddress();
```

## Signing Methods

In Solana providers, we provide three signing methods:

* `signMessage`
* `signTransaction`
* `signAndExecuteTransaction`

### Sign message

`signMessage` method will create a simple signed transaction for one message and return the signed transaction in hex.

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

### Sign transaction

`signTransaction` supports signing arbitrary PTB transactions if they are well formed. Please check [this ](https://docs.sui.io/guides/developer/sui-101/building-ptb)for the general construction of transactions. We provide two examples:

<pre class="language-typescript"><code class="lang-typescript"><strong>// define transaction body
</strong><strong>export const getSendSuiCoinTx = async ({
</strong>  fromAddress,
  toAddress,
  amount,
  coinType,
}: {
  fromAddress: string;
  toAddress: string;
  amount: string;
  coinType?: string;
}): Promise&#x3C;{ transaction: string; bytes: Uint8Array } | null> => {
  const suiClient = getSuiClient();
  const txb = new Transaction();
  
  txb.transferObjects(
    [coinWithBalance({ balance: Number(amount), type: coinType || undefined })],
    toAddress
  );
  
  try {
    txb.setSender(fromAddress);
    const transaction = (await txb.toJSON({ client: suiClient })).toString();
    const bytes = await txb.build({ client: suiClient });
    console.log('bytes', transaction, bytes);
    return { transaction, bytes };
  } catch (e) {
    console.warn(e);
    return null;
  }
};

// create transaction body for concrete transaction
const res = await getSendSuiCoinTx({
  fromAddress: addr,
  toAddress: toAddr2,
  amount: +toValue2 * 10 ** 6 + '',
  coinType: contractAddr,
});

// create transaction
const { transaction, bytes } = res || {};

const input = {
  transactionBlock: transaction,
  chain: 'sui:mainnet',
  txBytes: bytes,
  options: {
    showEffects: true,
  },
};

// sign transaction
const signed transaction= await sui.signTransaction(input);

// or you can use sign and send transaction at the same time

const res = await sui.signAndExecuteTransaction(input);
</code></pre>

After signing the transaction, you can send it to your client or add other signatures. In addition, you can use `signAndExecuteTransaction` the method to send the signed transaction directly.


---

# 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/sui-provider-beta.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.
