> ## 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.

# IOTA

## 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": "0x00000200080100000000000000002044732583a657f2d13bce82acc611e5ea6424508036f27e3a3277f24f55f9bfc60202000101000001010300000000010100b8737aab95b5d62407a921c23d26f28cd94da2df511276693a5cba782ae640ee01122efbd2244535c134ab802ad247b3ece73641e7ea8169b199bb6fa644af3ef32ffa94070000000020608d3f1e7023d0947f8274db06898744fadb3598769f8463070536ce489ca336b8737aab95b5d62407a921c23d26f28cd94da2df511276693a5cba782ae640eee803000000000000e06f3c000000000000"
}
```

### Typescript Example with IOTA SDK

First install the IOTA SDK. You can find the full documentation [here](https://docs.iota.org/developer/ts-sdk/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 { IotaClient } from '@iota/iota-sdk/client'
import { Transaction } from '@iota/iota-sdk/transactions'

const walletId = 'wa-4to1j-8tho9-xxxxxxxxxxxxxxxx'
const wallet = await dfnsClient.wallets.getWallet({ walletId })

const client = new IotaClient({ url: process.env.IOTA_RPC_URL! })

const transaction = new Transaction()
const [coin] = transaction.splitCoins(transaction.gas, [1])
transaction.transferObjects([coin], '0xb8737aab95b5d62407a921c23d26f28cd94da2df511276693a5cba782ae640ee')
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 complete working examples, see the SDK examples on GitHub:

* [Basic transaction](https://github.com/dfns/dfns-sdk-ts/tree/m/examples/libs/iota/basic-tx) - Simple IOTA transfer
* [Contract call](https://github.com/dfns/dfns-sdk-ts/tree/m/examples/libs/iota/contract-call) - Smart contract interactions
* [Lock/unlock transactions](https://github.com/dfns/dfns-sdk-ts/tree/m/examples/libs/iota/lock-unlock-transactions) - Timelocked and conditional transfers
