# sendrawtransaction

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://bitcoin-mainnet.g.alchemy.com/v2/{apiKey}

Broadcasts a raw transaction (hex-encoded) to the network. Useful for rebroadcasting transactions not originating from your wallet.


Reference: https://www.alchemy.com/docs/chains/bitcoin/bitcoin-api-endpoints/sendrawtransaction

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| hexstring | string | Yes | The hex-encoded raw transaction. |
| maxfeerate | number or string | No | Reject transactions whose fee rate is higher than this value (in BTC/kB). Set to 0 to disable the check.  |

## Result

**result** (string): The transaction ID (txid) of the submitted transaction.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "sendrawtransaction",
  "params": [
    "0200000000010153fc6712e0c6cbfd15e56743f2a16bba3c0b17837d4fd33d68d2d930739e2b130000000000ffffffff01c0c62d0000000000160014c24b61118d4a2b36257b65e1ea7f15f85e41ff0402483045022100ac32e935715a57ec1d642a5e178c37f74c013bf8e4edc4cb1c79f5352f136e87022020b0b3192347d1b84e9b89d00a2ecb290f18f9c39e514fa3ef2b7a889e7b6c1b012103ab0b56c7aa6254a80c124e04d2149f7fc376afedfe4623f3c59b87c279eaeb1400000000",
    0.1
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": "1b6d7a0196d78d84c31408982f8fa6bc7383d29c96c5e2b3a55e1f1575dc1cfb",
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "sendrawtransaction",
  "params": [
    "0200000000010153fc6712e0c6cbfd15e56743f2a16bba3c0b17837d4fd33d68d2d930739e2b130000000000ffffffff01c0c62d0000000000160014c24b61118d4a2b36257b65e1ea7f15f85e41ff0402483045022100ac32e935715a57ec1d642a5e178c37f74c013bf8e4edc4cb1c79f5352f136e87022020b0b3192347d1b84e9b89d00a2ecb290f18f9c39e514fa3ef2b7a889e7b6c1b012103ab0b56c7aa6254a80c124e04d2149f7fc376afedfe4623f3c59b87c279eaeb1400000000",
    0.1
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'sendrawtransaction',
    params: [
      '0200000000010153fc6712e0c6cbfd15e56743f2a16bba3c0b17837d4fd33d68d2d930739e2b130000000000ffffffff01c0c62d0000000000160014c24b61118d4a2b36257b65e1ea7f15f85e41ff0402483045022100ac32e935715a57ec1d642a5e178c37f74c013bf8e4edc4cb1c79f5352f136e87022020b0b3192347d1b84e9b89d00a2ecb290f18f9c39e514fa3ef2b7a889e7b6c1b012103ab0b56c7aa6254a80c124e04d2149f7fc376afedfe4623f3c59b87c279eaeb1400000000',
      0.1
    ]
  })
};

fetch('https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "sendrawtransaction",
    "params": ["0200000000010153fc6712e0c6cbfd15e56743f2a16bba3c0b17837d4fd33d68d2d930739e2b130000000000ffffffff01c0c62d0000000000160014c24b61118d4a2b36257b65e1ea7f15f85e41ff0402483045022100ac32e935715a57ec1d642a5e178c37f74c013bf8e4edc4cb1c79f5352f136e87022020b0b3192347d1b84e9b89d00a2ecb290f18f9c39e514fa3ef2b7a889e7b6c1b012103ab0b56c7aa6254a80c124e04d2149f7fc376afedfe4623f3c59b87c279eaeb1400000000", 0.1]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"sendrawtransaction\",\n  \"params\": [\n    \"0200000000010153fc6712e0c6cbfd15e56743f2a16bba3c0b17837d4fd33d68d2d930739e2b130000000000ffffffff01c0c62d0000000000160014c24b61118d4a2b36257b65e1ea7f15f85e41ff0402483045022100ac32e935715a57ec1d642a5e178c37f74c013bf8e4edc4cb1c79f5352f136e87022020b0b3192347d1b84e9b89d00a2ecb290f18f9c39e514fa3ef2b7a889e7b6c1b012103ab0b56c7aa6254a80c124e04d2149f7fc376afedfe4623f3c59b87c279eaeb1400000000\",\n    0.1\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"sendrawtransaction\",\n  \"params\": [\n    \"0200000000010153fc6712e0c6cbfd15e56743f2a16bba3c0b17837d4fd33d68d2d930739e2b130000000000ffffffff01c0c62d0000000000160014c24b61118d4a2b36257b65e1ea7f15f85e41ff0402483045022100ac32e935715a57ec1d642a5e178c37f74c013bf8e4edc4cb1c79f5352f136e87022020b0b3192347d1b84e9b89d00a2ecb290f18f9c39e514fa3ef2b7a889e7b6c1b012103ab0b56c7aa6254a80c124e04d2149f7fc376afedfe4623f3c59b87c279eaeb1400000000\",\n    0.1\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"sendrawtransaction\",\n  \"params\": [\n    \"0200000000010153fc6712e0c6cbfd15e56743f2a16bba3c0b17837d4fd33d68d2d930739e2b130000000000ffffffff01c0c62d0000000000160014c24b61118d4a2b36257b65e1ea7f15f85e41ff0402483045022100ac32e935715a57ec1d642a5e178c37f74c013bf8e4edc4cb1c79f5352f136e87022020b0b3192347d1b84e9b89d00a2ecb290f18f9c39e514fa3ef2b7a889e7b6c1b012103ab0b56c7aa6254a80c124e04d2149f7fc376afedfe4623f3c59b87c279eaeb1400000000\",\n    0.1\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: sendrawtransaction
summary: Submit a raw transaction to the Bitcoin network
description: |
  Broadcasts a raw transaction (hex-encoded) to the network. Useful for rebroadcasting transactions not originating from your wallet.
params:
  - name: hexstring
    required: true
    description: The hex-encoded raw transaction.
    schema:
      title: Raw Transaction Hex
      type: string
      pattern: ^[a-fA-F0-9]+$
      description: A serialized, hex-encoded Bitcoin transaction.
  - name: maxfeerate
    required: false
    description: |
      Reject transactions whose fee rate is higher than this value (in BTC/kB). Set to 0 to disable the check.
    schema:
      oneOf:
        - type: number
        - type: string
result:
  name: result
  description: The transaction ID (txid) of the submitted transaction.
  schema:
    type: string
examples:
  - name: sendrawtransaction example
    params:
      - name: hexstring
        value: 0200000000010153fc6712e0c6cbfd15e56743f2a16bba3c0b17837d4fd33d68d2d930739e2b130000000000ffffffff01c0c62d0000000000160014c24b61118d4a2b36257b65e1ea7f15f85e41ff0402483045022100ac32e935715a57ec1d642a5e178c37f74c013bf8e4edc4cb1c79f5352f136e87022020b0b3192347d1b84e9b89d00a2ecb290f18f9c39e514fa3ef2b7a889e7b6c1b012103ab0b56c7aa6254a80c124e04d2149f7fc376afedfe4623f3c59b87c279eaeb1400000000
      - name: maxfeerate
        value: 0.1
    result:
      name: result
      value: 1b6d7a0196d78d84c31408982f8fa6bc7383d29c96c5e2b3a55e1f1575dc1cfb
```
