# Transactions

Operations related to broadcasting and retrieving transactions.

## Broadcast raw transaction

> Broadcast raw transactions on the network. You can use the \[@stacks/transactions]\(<https://github.com/blockstack/stacks.js)\\>
> project to generate a raw transaction payload.\
> \
> The node performs static validation checks on transactions before accepting them into the mempool, including:\
> \- Transaction format validation\
> \- Signature verification\
> \- Nonce checking\
> \- Fee validation\
> \- Size limits<br>

```json
{"openapi":"3.1.0","info":{"title":"Stacks 3.0+ RPC API","version":"1.0.0"},"tags":[{"name":"Transactions","description":"Operations related to broadcasting and retrieving transactions."}],"servers":[{"url":"http://localhost:20443","description":"Local Stacks Node"},{"url":"https://api.mainnet.hiro.so","description":"Stacks Mainnet API"},{"url":"https://api.testnet.hiro.so","description":"Stacks Testnet API"}],"security":[],"paths":{"/v2/transactions":{"post":{"summary":"Broadcast raw transaction","tags":["Transactions"],"description":"Broadcast raw transactions on the network. You can use the [@stacks/transactions](https://github.com/blockstack/stacks.js)\nproject to generate a raw transaction payload.\n\nThe node performs static validation checks on transactions before accepting them into the mempool, including:\n- Transaction format validation\n- Signature verification\n- Nonce checking\n- Fee validation\n- Size limits\n","operationId":"broadcastTransaction","requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary","minLength":1}},"application/json":{"schema":{"type":"object","required":["tx"],"properties":{"tx":{"type":"string","pattern":"^[0-9a-f]+$","description":"Hex-encoded transaction"},"attachment":{"type":"string","pattern":"^[0-9a-f]+$","description":"Optional hex-encoded attachment for contract-call transactions"}}}}}},"responses":{"200":{"description":"Transaction ID of successful post of a raw tx to the node's mempool.","content":{"application/json":{"schema":{"type":"string","pattern":"^[0-9a-f]{64}$"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"description":"Describes a transaction submission error response","type":"object","required":["error","reason","txid"],"properties":{"error":{"type":"string","description":"The error"},"reason":{"type":"string","description":"The reason for the error"},"reason_data":{"type":"object","description":"More details about the reason","properties":{"actual":{"type":"integer"},"expected":{"type":"integer"},"is_origin":{"type":"boolean"},"principal":{"type":"string"}}},"txid":{"type":"string","description":"The relevant transaction id"}}}},"text/plain":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"text/plain":{"schema":{"type":"string"}}}}}}}}}
```

## Retrieve transaction details by TXID

> Get a JSON with the transaction details including the \`index\_block\_hash\`,\
> the hex-encoded transaction body, and the \`result\`.<br>

```json
{"openapi":"3.1.0","info":{"title":"Stacks 3.0+ RPC API","version":"1.0.0"},"tags":[{"name":"Transactions","description":"Operations related to broadcasting and retrieving transactions."}],"servers":[{"url":"http://localhost:20443","description":"Local Stacks Node"},{"url":"https://api.mainnet.hiro.so","description":"Stacks Mainnet API"},{"url":"https://api.testnet.hiro.so","description":"Stacks Testnet API"}],"security":[],"paths":{"/v3/transaction/{txid}":{"get":{"summary":"Retrieve transaction details by TXID","tags":["Transactions"],"description":"Get a JSON with the transaction details including the `index_block_hash`,\nthe hex-encoded transaction body, and the `result`.\n","operationId":"getTransactionById","parameters":[{"name":"txid","in":"path","required":true,"description":"Transaction ID (64 hexadecimal characters)","schema":{"type":"string","pattern":"^[0-9a-f]{64}$"}}],"responses":{"200":{"description":"Transaction JSON with index_block_hash, transaction body and result","content":{"application/json":{"schema":{"type":"object","required":["index_block_hash","tx","result"],"properties":{"index_block_hash":{"type":"string","description":"Block hash where the transaction was included","pattern":"^[0-9a-f]{64}$"},"tx":{"type":"string","description":"Hex-encoded transaction"},"result":{"type":"string","description":"Transaction execution result (Clarity value)"},"block_height":{"type":["integer","null"],"description":"Height of the block where the transaction was included"},"is_canonical":{"type":"boolean","description":"Whether the block where this transaction was included is in the canonical chain tip"}}}}}},"400":{"description":"Bad request","content":{"text/plain":{"schema":{"type":"string"}}}},"404":{"description":"Not found","content":{"text/plain":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"text/plain":{"schema":{"type":"string"}}}},"501":{"description":"Transaction indexing not enabled","content":{"text/plain":{"schema":{"type":"string"}}}}}}}}}
```

## Get unconfirmed transaction

> Get an unconfirmed transaction by its transaction ID.\
> This looks in both the mempool and unconfirmed microblock stream.<br>

```json
{"openapi":"3.1.0","info":{"title":"Stacks 3.0+ RPC API","version":"1.0.0"},"tags":[{"name":"Transactions","description":"Operations related to broadcasting and retrieving transactions."}],"servers":[{"url":"http://localhost:20443","description":"Local Stacks Node"},{"url":"https://api.mainnet.hiro.so","description":"Stacks Mainnet API"},{"url":"https://api.testnet.hiro.so","description":"Stacks Testnet API"}],"security":[],"paths":{"/v2/transactions/unconfirmed/{txid}":{"get":{"summary":"Get unconfirmed transaction","tags":["Transactions"],"operationId":"getUnconfirmedTransactionById","description":"Get an unconfirmed transaction by its transaction ID.\nThis looks in both the mempool and unconfirmed microblock stream.\n","parameters":[{"name":"txid","in":"path","required":true,"description":"Transaction ID (64 hexadecimal characters)","schema":{"type":"string","pattern":"^[0-9a-f]{64}$"}}],"responses":{"200":{"description":"Unconfirmed transaction details","content":{"application/json":{"schema":{"type":"object","properties":{"tx":{"type":"string","description":"Hex-encoded transaction data"},"status":{"oneOf":[{"type":"object","properties":{"Microblock":{"type":"object","properties":{"block_hash":{"type":"string","description":"Block hash containing the microblock"},"seq":{"type":"integer","description":"Microblock sequence number"}}}}},{"type":"string","enum":["Mempool"]}]}}}}}},"400":{"description":"Bad request","content":{"text/plain":{"schema":{"type":"string"}}}},"404":{"description":"Not found","content":{"text/plain":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"text/plain":{"schema":{"type":"string"}}}}}}}}}
```

## Query mempool for missing transactions

> Query the mempool for transactions that might be missing from the requesting node.\
> This endpoint supports pagination and streaming of transaction data.<br>

```json
{"openapi":"3.1.0","info":{"title":"Stacks 3.0+ RPC API","version":"1.0.0"},"tags":[{"name":"Transactions","description":"Operations related to broadcasting and retrieving transactions."}],"servers":[{"url":"http://localhost:20443","description":"Local Stacks Node"},{"url":"https://api.mainnet.hiro.so","description":"Stacks Mainnet API"},{"url":"https://api.testnet.hiro.so","description":"Stacks Testnet API"}],"security":[],"paths":{"/v2/mempool/query":{"post":{"summary":"Query mempool for missing transactions","tags":["Transactions"],"operationId":"queryMempool","description":"Query the mempool for transactions that might be missing from the requesting node.\nThis endpoint supports pagination and streaming of transaction data.\n","parameters":[{"name":"page_id","in":"query","description":"Transaction ID to start pagination from","schema":{"type":"string","pattern":"^[0-9a-f]{64}$"}}],"requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary","minLength":1,"description":"Binary SIP-003 encoding of `MemPoolSyncData`\n(`BloomFilter` or `TxTags` variants).\n"}}}},"responses":{"200":{"description":"Stream of missing transactions","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary","description":"Binary stream of transactions and pagination data.\nThe stream contains serialized transactions followed by a page ID for continuation.\n"}}}},"400":{"description":"Bad request","content":{"text/plain":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"text/plain":{"schema":{"type":"string"}}}}}}}}}
```
