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.
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). | String (optional) |
{
"kind": "Transaction",
"transaction": "0x00000200080100000000000000002044732583a657f2d13bce82acc611e5ea6424508036f27e3a3277f24f55f9bfc60202000101000001010300000000010100b8737aab95b5d62407a921c23d26f28cd94da2df511276693a5cba782ae640ee01122efbd2244535c134ab802ad247b3ece73641e7ea8169b199bb6fa644af3ef32ffa94070000000020608d3f1e7023d0947f8274db06898744fadb3598769f8463070536ce489ca336b8737aab95b5d62407a921c23d26f28cd94da2df511276693a5cba782ae640eee803000000000000e06f3c000000000000"
}
Typescript Example with IOTA SDK
First install the IOTA SDK. You can find the full documentation here
Here a code sample to broadcast a transaction via the Dfns TypeScript SDK:
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: