> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dfns.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Sui

> Reference for Sui transaction payloads used with the Dfns sign and sign-and-broadcast endpoints, including required and optional fields.

## Transaction

Signs an unsigned transaction and broadcasts it to chain.

| Field         | Description                                                                                                                                                           | Type - Optional     |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
| `kind`        | `Transaction`                                                                                                                                                         | String              |
| `transaction` | The unsigned hex encoded transaction as shown below.                                                                                                                  | String              |
| `externalId`  | A unique ID from your system. It can be leveraged to be used as an idempotency key (read more [here](https://docs-legacy.dfns.co/d/advanced-topics/api-idempotency)). | String *(optional)* |

```shell theme={null}
{
  "kind": "Transaction",
  "transaction": "0x0000020008010000000000000000201d9c96adb0eda0b3beca44ed89143444b4147b30f06eef7bfc39cbbff848f6e5020200010100000101030000000001010020d672470dc607fe9afb01f4c20778716ebeb69a542e7a7dea9bebafdbd28546016d03aa3a104560ced4e75b988fcd5913576258fe664c7d6a8f27f065c36035a5ae11d0140000000020a4053ac8443987ed5f189777e783ddb7570e46f3ec31eef082d0b35c9d5ef88120d672470dc607fe9afb01f4c20778716ebeb69a542e7a7dea9bebafdbd28546e80300000000000040ab3c000000000000"
}
```

### Typescript Example with Sui SDK

First install the Sui SDK. You can find the full documentation [here](https://sdk.mystenlabs.com/typescript).

Here a code sample to broadcast a transaction via [the Dfns TypeScript SDK](https://github.com/dfns/dfns-sdk-ts):

```typescript theme={null}
import { SuiClient } from '@mysten/sui/client'
import { Transaction } from '@mysten/sui/transactions'

const walletId = 'wa-3b6ka-b6a4k-xxxxxxxxxxxxxxxx'
const wallet = await dfnsClient.wallets.getWallet({ walletId })

const client = new SuiClient({ url: process.env.SUI_RPC_URL! })

const transaction = new Transaction()
const [coin] = transaction.splitCoins(transaction.gas, [1])
transaction.transferObjects([coin], '0x20d672470dc607fe9afb01f4c20778716ebeb69a542e7a7dea9bebafdbd28546')
transaction.setSender(wallet.address!)
const bytes = await transaction.build({ client })

const res = await dfnsClient.wallets.broadcastTransaction({
  walletId,
  body: {
    kind: 'Transaction',
    transaction: `0x${Buffer.from(bytes).toString('hex')}`,
  },
})
```

## Complete examples

For a complete working example, see the SDK example on GitHub:

* [Basic transaction](https://github.com/dfns/dfns-sdk-ts/tree/m/examples/libs/sui/basic-tx) - Simple SUI transfer using Sui SDK
