# Broadcast Transactions

If you'd like your transactions to also be broadcast to the associated blockchain network for each `ContractAction` created, you can pass in the optional broadcast parameter as `true` to the `start` method.&#x20;

{% code overflow="wrap" fullWidth="true" %}

```typescript
await newCircuit.start({publicKey, ipfsCID, authSig, broadcast: true});
```

{% endcode %}

{% hint style="warning" %}
Please note that broadcast is only supported for `ContractActions`. If any of your transaction data is under funded or unapproved the broadcast will be unsuccessful and an error logged and thrown.&#x20;

Make sure your PKP address or other wallets are correctly funded and approved on the network specified in each `ContractAction`.
{% endhint %}

For a more **reliable** and **controlled** experience it's suggested that you broadcast your transactions outside of the SDK, which is necessary anyway if you plan to broadcast any `FetchAction` or `CustomAction` signed data. **Broadcasts are non blocking to each run of the circuit.**

For a quick start to broadcasting your signed transactions, obtain the correct unsigned transaction data parameters returned in the SetActions object. You can also create this manually yourself by invoking `generateUnsignedTransactionData` .

{% code overflow="wrap" fullWidth="true" %}

```typescript
// Generate or obtain the constructed unsigned transaction data.
const {unsignedTransactionDataObject, LitActionCode} = await newCircuit.setActions([contractAction]);
```

{% endcode %}

The `unsignedTransactionDataObject` is populated according to the number of `ContractActions` added in `SetActions`. Each field within this object is named in the following format: `generatedUnsignedDataContract${priorityNumberOfTheAction}`.

{% code overflow="wrap" fullWidth="true" %}

```typescript
unsignedTransactionDataObject = {
      generatedUnsignedDataContract1: {
      "to": "0x123abc...",
      "nonce": 0,
      "chainId": 137,
      "gasLimit": { "_hex": "0x186a0", "_isBigNumber": true },
      "maxFeePerGas": { "_hex": "0x2dc6c0", "_isBigNumber": true },
      "maxPriorityFeePerGas": { "_hex": "0x16e360", "_isBigNumber": true },
      "from": "0xabc123...",
      "data": "0xa9059cbb0000000000000000000000005beeb...",
      "value": { "_hex": "0x0", "_isBigNumber": true },
      "type": 2
  },
      generatedUnsignedDataContract2: {
        "to": "0xdef456...",
        "nonce": 2,
        "chainId": 137,
        "gasLimit": { "_hex": "0x186a0", "_isBigNumber": true },
        "maxFeePerGas": { "_hex": "0x2dc6c0", "_isBigNumber": true },
        "maxPriorityFeePerGas": { "_hex": "0x16e360", "_isBigNumber": true },
        "from": "0x456def...",
        "data": "0xa9059cbb0000000000000000000000004abcf...",
        "value": { "_hex": "0x0", "_isBigNumber": true },
        "type": 2
  }
}
```

{% endcode %}

This transaction data can then be serialized alongside the returned `s,r,recid` values from the signed transaction response object in the `LogCategory.RESPONSE` field.

{% code overflow="wrap" fullWidth="true" %}

```typescript
import { joinSignature } from "@ethersproject/bytes";

// The latestBroadcastLog will contain the broadcast information of the last signed transaction i.e. generatedUnsignedDataContract2. To access generatedUnsignedDataContract1 take newCircuit.getLogs(LogCategory.Broadcast)[1]. Assuming the circuit has done one execution run. 
const latestBroadcastLog = newCircuit.getLogs(LogCategory.Broadcast)[0];
const sig = JSON.parse(latestBroadcastLog.responseObject).signatures.contract1;

const encodedSignature = joinSignature({r: "0x" + sig.r, s: "0x" + sig.s, recoveryParam: sig.recid});

// Make sure your provider url and chainId matches the chain that was specified for the added contract action.
const provider = new ethers.providers.JsonRpcProvider("https://provider-url.com", 137);

// Serialize the correct tx data with the associated encoded signature.
const serialized = serialize(generatedUnsignedDataContract2,encodedSignature);

const transactionHash = await provider.sendTransaction(serialized);
await transactionHash.wait();
```

{% endcode %}


---

# 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.irrevocable.dev/sdk-reference/broadcast-transactions.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.
