# Broadcast DApp Transaction

Relay an already-signed raw EVM transaction to the RPC node of the given chain.

## Overview

The server sends `signedTransaction` unchanged with `eth_sendRawTransaction` and returns the transaction hash reported by the node. It does not decode the transaction, check who signed it, or create an Aurea transaction record. The dApps endpoints never sign transactions — sign with a key you control first (see [DApps Browser](https://docs.aureahub.com/docs/guide-dapps.md)).

- `chainSlug` must be a registered chain with an RPC URL, otherwise `400` (`UNKNOWN_CHAIN` or `NO_RPC_URL`).
- If the node rejects the transaction, the call returns `422` with the node's error message.
- If the node does not answer within 15 seconds, the call returns `504` `RPC_TIMEOUT`.
- Rate limit: 10 requests per 10 seconds.

## Endpoint

### `POST /v1/dapps/broadcast`

Authentication: bearer token required.

Broadcasts a signed raw transaction with eth_sendRawTransaction and returns the transaction hash.

**Request body**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `signedTransaction` | string | yes | `0x`-prefixed hex of the signed raw transaction. |
| `chainSlug` | string | yes | Chain identifier, e.g. `gnosis`. |

**Responses**

`200` OK

```json
{ "txHash": "0x…32-byte transaction hash…" }
```

`400` Unknown Chain

```json
{
  "error": "UNKNOWN_CHAIN",
  "message": "Chain 'unknownchain' is not registered"
}
```

`422` RPC Error

```json
{
  "error": "RPC_ERROR",
  "message": "error message returned by the RPC node"
}
```

**Example request**

```bash
curl -X POST https://api.aureahub.com/v1/dapps/broadcast \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"chainSlug": "gnosis", "signedTransaction": "0x02f8..."}'
```

## Implementation

```javascript
async function broadcastDappTx(token, chainSlug, signedTransaction) {
  const res = await fetch('https://api.aureahub.com/v1/dapps/broadcast', {
    method: 'POST',
    headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
    body: JSON.stringify({ chainSlug, signedTransaction })
  });
  if (!res.ok) {
    const { error, message } = await res.json();   // e.g. RPC_ERROR, RPC_TIMEOUT
    throw new Error(`${error}: ${message}`);
  }
  const { txHash } = await res.json();
  return txHash;
}
```

---

Web version: https://docs.aureahub.com/#dapps-broadcast
