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

# Signing And Broadcasting

> To convert a Demoswork object to a transaction, use the `prepareDemosWorkPayload` function.

# Signing and broadcasting

To convert a Demoswork object to a transaction, use the `prepareDemosWorkPayload` function.

```ts theme={null}
import { Demos } from "@kynesyslabs/demosdk/websdk"
import { prepareDemosWorkPayload } from "@kynesyslabs/demosdk/demoswork"

const demos = new Demos()
await demos.connect("https://node2.demos.sh")
await demos.connectWallet(mnemonic)

// `work` is the DemosWork object built in the previous steps
// (see "Creating Work Steps", "Conditional Operation", or "Base Operation").
const tx = await prepareDemosWorkPayload(work, demos)
```

### Broadcasting the transaction

You can broadcast the transaction using the `confirm` and `broadcast` methods of the `demos` object.

```ts theme={null}
// Confirming the transaction
const validityData = await demos.confirm(tx)

// Broadcasting the transaction
const res = await demos.broadcast(validityData)
console.log("res:", res)
```

If you need a deterministic confirmation that the work transaction landed on chain, use [`broadcastAndWait`](/sdk/websdk/transactions/broadcasting-a-transaction#broadcast-and-wait-for-inclusion) instead — it broadcasts and then polls until the transaction reaches a terminal `included` or `failed` state.

```ts theme={null}
const { broadcast, status } = await demos.broadcastAndWait(validityData)
console.log("status:", status.state, "block:", status.blockNumber)
```
