### Quickstart Page MDX Template
Source: https://github.com/hirosystems/docs/blob/main/README.md
Template for a quickstart page in MDX, featuring frontmatter, objectives, prerequisites, and a step-by-step guide using the Steps component.
```mdx
---
title: Quickstart
description: Learn how to [task] with [tool]
---
Brief intro paragraph about what you'll build.
:::objectives
- Learning objective 1
- Learning objective 2
:::
:::prerequisites
- Prerequisites
:::
## Quickstart
[3-5 focused steps]
:::next-steps
- [Next Guide](/path): Description
:::
```
--------------------------------
### Terminal Command Example
Source: https://github.com/hirosystems/docs/blob/main/README.md
Demonstrates a basic terminal command for installing a tool using Homebrew on macOS.
```terminal
$ brew install tool
```
--------------------------------
### Windows Package Installation
Source: https://github.com/hirosystems/docs/blob/main/README.md
Shows how to install a tool using winget on Windows.
```terminal
$ winget install tool
```
--------------------------------
### Start the Stacks node service
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/resources/guides/sync-a-stacks-node.mdx
Make the management script executable and then start the Stacks node. Replace `` with 'mainnet', 'testnet', or 'mocknet' depending on your needs.
```bash
chmod +x manage.sh
./manage.sh -n -a start
```
--------------------------------
### Making a Basic RPC Request
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-node-rpc-api/usage.mdx
This example demonstrates how to make a simple GET request to the `/v2/info` endpoint using curl. It includes the necessary Accept header for JSON responses.
```APIDOC
## GET /v2/info
### Description
Retrieves general information about the Stacks node.
### Method
GET
### Endpoint
/v2/info
### Request Example
```bash
curl -L 'https://api.hiro.so/v2/info' \
-H 'Accept: application/json'
```
### Response
#### Success Response (200)
- **data** (object) - Contains node information.
#### Response Example
```json
{
"netid": 10,
" ஒப்பந்த_id ": 12345,
"burn_block_hash": "0x...",
"cliff": 1000,
"epoch": "mainnet",
"height": 123456,
"latest_block_hash": "0x...",
"parent_burn_block_hash": "0x...",
"state_root": "0x...",
"stable_block_hash": "0x...",
"stable_height": 123450,
"stacks_chain_id": "01000000",
"stacks_height": 123456,
"stacks_tip_hash": "0x...",
"stacks_tip_height": 123456,
"stacks_tip_version": "0.0.0",
"tx_index_enabled": true
}
```
```
--------------------------------
### Making a Basic Request
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/token-metadata-api/usage.mdx
This example shows how to make a basic GET request to the Token Metadata API to retrieve fungible token (ft) metadata. Ensure you replace the placeholder URL with the actual API endpoint.
```APIDOC
## GET /metadata/v1/ft
### Description
Retrieves fungible token metadata.
### Method
GET
### Endpoint
`https://api.hiro.so/metadata/v1/ft`
### Request Example
```bash
curl -L 'https://api.hiro.so/metadata/v1/ft' \
-H 'Accept: application/json'
```
### Response
#### Success Response (200)
- **data** (array) - An array of fungible token metadata objects.
#### Response Example
```json
{
"data": [
{
"asset_id": "0x0100000000000000000000000000000000000000000000000000000000000000",
"name": "Example Token",
"symbol": "EXT",
"icon_uri": "https://example.com/icon.png",
"decimals": 6,
"description": "This is an example fungible token.",
"native_decimals": 6,
"native_symbol": "EXT"
}
]
}
```
```
--------------------------------
### Example bitcoin.conf Configuration
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/resources/guides/sync-a-bitcoin-node.mdx
A comprehensive example of a bitcoin.conf file, including settings for RPC, ZeroMQ, and network parameters. This configuration is suitable for running a Bitcoin node for development purposes.
```bash
datadir=/your-path-to/bitcoin-data/
server=1
rpcuser=devnet
rpcpassword=devnet
rpcport=8332
rpcallowip=0.0.0.0/0
rpcallowip=::/0
txindex=1
listen=1
discover=0
dns=0
dnsseed=0
listenonion=0
rpcserialversion=1
disablewallet=0
fallbackfee=0.00001
rpcthreads=8
blocksonly=1
dbcached=4096
# Start zeromq
zmqpubhashblock=tcp://0.0.0.0:18543
```
--------------------------------
### Install Chainhooks SDK
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/tools/chainhooks/(chainhook-sdk)/introduction.mdx
Install the Chainhooks SDK using your preferred package manager.
```bash
$ npm install @hirosystems/chainhooks-client
```
```bash
$ yarn add @hirosystems/chainhooks-client
```
```bash
$ pnpm add @hirosystems/chainhooks-client
```
```bash
$ bun add @hirosystems/chainhooks-client
```
--------------------------------
### Make a GET Request to Chainhooks
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/platform-api/usage.mdx
Example cURL command to fetch chainhooks from the Platform API. Replace `{apiKey}` with your actual API key.
```terminal
$ curl -L 'https://api.platform.hiro.so/v1/ext/{apiKey}/chainhooks' \
-H 'Accept: application/json'
```
--------------------------------
### Package Install Block
Source: https://github.com/hirosystems/docs/blob/main/README.md
Auto-generates npm, yarn, or pnpm commands for installing a package. Use this for package installation instructions.
```package-install
@stacks/connect # Auto-generates npm/yarn/pnpm commands
```
--------------------------------
### Get Stacks Node Info
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-node-rpc-api/index.mdx
Use this command to retrieve general information about the Stacks node. This is a basic example of interacting with the RPC API.
```bash
$ curl -L 'https://api.hiro.so/v2/info' -H 'Accept: application/json'
```
--------------------------------
### Making a Basic Request
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/usage.mdx
This example demonstrates how to make a basic GET request to the Stacks API using curl. It specifies the base URL and sets the 'Accept' header to 'application/json'.
```APIDOC
## Making a Basic Request
### Description
This example demonstrates how to make a basic GET request to the Stacks API using curl. It specifies the base URL and sets the 'Accept' header to 'application/json'.
### Method
GET
### Endpoint
https://api.hiro.so/extended
### Request Example
```bash
curl -L 'https://api.hiro.so/extended' \
-H 'Accept: application/json'
```
### Response
#### Success Response (200)
- **body** (object) - The response body containing the requested data.
#### Response Example
```json
{
"example": "response body"
}
```
```
--------------------------------
### Start Bitcoin Node Sync
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/resources/guides/sync-a-bitcoin-node.mdx
Command to start the Bitcoin Core daemon and begin syncing the blockchain. Ensure you provide the correct paths to the bitcoind executable and your configuration file.
```terminal
$ /Volumes/SSD/bitcoin-25.0/bin/bitcoind -conf=/Volumes/SSD/bitcoin-25.0/bitcoin.conf
```
--------------------------------
### Rate Limit Handling Example
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/chainhooks-api/usage.mdx
JavaScript example demonstrating how to implement exponential backoff for handling rate limit errors (429).
```APIDOC
## Rate Limit Handling Example
### Description
This JavaScript code snippet demonstrates how to implement an exponential backoff strategy to automatically retry requests when the API returns a `429 Too Many Requests` status code.
### Code Example
```javascript
async function makeRequestWithRetry(url, options, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
const response = await fetch(url, options);
if (response.status === 429) {
const delay = Math.pow(2, i) * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
return response;
}
throw new Error('Max retries exceeded');
}
```
```
--------------------------------
### Making a Request to Chainhooks
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/platform-api/usage.mdx
This example demonstrates how to make a GET request to the chainhooks endpoint using curl. It includes the necessary headers for accepting JSON responses.
```APIDOC
## GET /v1/ext/{apiKey}/chainhooks
### Description
Retrieves information about chainhooks associated with the provided API key.
### Method
GET
### Endpoint
/v1/ext/{apiKey}/chainhooks
### Parameters
#### Path Parameters
- **apiKey** (string) - Required - Your Platform API key.
#### Headers
- **Accept**: application/json
### Request Example
```bash
curl -L 'https://api.platform.hiro.so/v1/ext/{apiKey}/chainhooks' \
-H 'Accept: application/json'
```
### Response
#### Success Response (200)
- **body** (object) - Contains chainhook information.
```
--------------------------------
### Making a Request to Signer Metrics API
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/signer-metrics-api/usage.mdx
Example of how to make a GET request to the Signer Metrics API using curl. This command fetches data for a specific cycle.
```terminal
$ curl -L 'https://api.hiro.so/signer-metrics/v1/cycles/95/signers' \
-H 'Accept: application/json'
```
--------------------------------
### Get all namespaces
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/names/namespaces.mdx
Retrieves a list of all namespaces known to the node.
```APIDOC
## GET /v1/namespaces/
### Description
Retrieves a list of all namespaces known to the node.
### Method
GET
### Endpoint
/v1/namespaces/
```
--------------------------------
### Make a Basic GET Request to Stacks API
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/usage.mdx
Use this cURL command to make a basic GET request to the Stacks API. The `-L` flag follows redirects, and the `Accept` header specifies the desired response format.
```terminal
$ curl -L 'https://api.hiro.so/extended' \
-H 'Accept: application/json'
```
--------------------------------
### Authentication Example
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/chainhooks-api/usage.mdx
Demonstrates how to authenticate API requests using an API key in the `x-api-key` header.
```APIDOC
## Authentication Example
### Description
This example shows how to make a request to the Chainhooks API, including the necessary authentication header.
### Method
GET
### Endpoint
`/me/`
### Headers
- `x-api-key` (string) - Required - Your Hiro API key
### Request Example
```bash
curl https://api.testnet.hiro.so/chainhooks/v1/me/ \
-H "x-api-key: YOUR_API_KEY"
```
```
--------------------------------
### Package Installation Picker
Source: https://github.com/hirosystems/docs/blob/main/content/_hidden/docskit.mdx
Use the `package-install` language to display a picker for JavaScript package managers.
```package-install
@stacks/connect
```
--------------------------------
### Start Devnet
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/platform-api/reference/devnet/start.mdx
Initiates a development network (devnet) for a specified project using an API key.
```APIDOC
## PUT /v1/ext/{apiKey}/devnet/{projectName}
### Description
Starts a development network (devnet) for a given project.
### Method
PUT
### Endpoint
/v1/ext/{apiKey}/devnet/{projectName}
### Parameters
#### Path Parameters
- **apiKey** (string) - Required - The API key for authentication.
- **projectName** (string) - Required - The name of the project for which to start the devnet.
### Request Example
```json
{
"example": "PUT /v1/ext/yourApiKey/devnet/yourProjectName"
}
```
### Response
#### Success Response (200)
This endpoint does not specify a success response body in the documentation. Typically, a successful start would be indicated by a 200 OK status code or a 204 No Content status code if no body is returned.
```
--------------------------------
### Get Latest and Last Sortitions
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-node-rpc-api/reference/sortitions/latest-and-last-sortitions.mdx
This endpoint retrieves information about the latest and last sortitions. It is a GET request to the /v3/sortitions/latest_and_last path.
```APIDOC
## GET /v3/sortitions/latest_and_last
### Description
Retrieves information about the latest and last sortitions.
### Method
GET
### Endpoint
/v3/sortitions/latest_and_last
### Parameters
### Request Example
(No request body for GET requests)
### Response
#### Success Response (200)
(Response schema is defined in the OpenAPI specification)
#### Response Example
(Example response will depend on the actual data returned by the API)
```
--------------------------------
### Chainhooks Client Initialization with Base URLs
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/tools/chainhooks/(chainhook-sdk)/introduction.mdx
Shows how to initialize the Chainhooks client for both testnet and mainnet environments using provided base URL constants.
```APIDOC
## Initialize Chainhooks Client with Base URLs
### Description
This example demonstrates how to initialize the `ChainhooksClient` for different network environments (testnet and mainnet) by utilizing the predefined `CHAINHOOKS_BASE_URL` constants. It also shows how to include your API key, which should be securely managed.
### Method
`new ChainhooksClient(options)`
### Parameters
#### Request Body
- **baseUrl** (string) - Required - The base URL for the Chainhooks API. Use `CHAINHOOKS_BASE_URL.testnet` or `CHAINHOOKS_BASE_URL.mainnet`.
- **apiKey** (string) - Required - Your API key for authentication. Store securely, e.g., in environment variables.
### Request Example
```typescript
import { ChainhooksClient, CHAINHOOKS_BASE_URL } from '@hirosystems/chainhooks-client';
// Testnet (for development)
const testnetClient = new ChainhooksClient({
baseUrl: CHAINHOOKS_BASE_URL.testnet,
apiKey: process.env.HIRO_API_KEY!,
});
// Mainnet (for production)
const mainnetClient = new ChainhooksClient({
baseUrl: CHAINHOOKS_BASE_URL.mainnet,
apiKey: process.env.HIRO_API_KEY!,
});
```
```
--------------------------------
### Chainhooks Client Initialization and Registration
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/tools/chainhooks/(chainhook-sdk)/introduction.mdx
Demonstrates how to initialize the Chainhooks client and register a new chainhook with specific filters and actions.
```APIDOC
## Initialize Client and Register Chainhook
### Description
This example shows how to create an instance of the `ChainhooksClient` and then use it to register a new chainhook. The registration includes defining the chainhook's version, name, target chain and network, filtering criteria (e.g., contract calls), the action to perform (e.g., HTTP POST), and optional settings like decoding Clarity values.
### Method
`client.registerChainhook(options)`
### Parameters
#### Request Body
- **version** (string) - Required - The version of the chainhook definition.
- **name** (string) - Required - A unique name for the chainhook.
- **chain** (string) - Required - The blockchain chain (e.g., 'stacks').
- **network** (string) - Required - The network (e.g., 'testnet', 'mainnet').
- **filters** (object) - Required - Criteria for triggering the chainhook.
- **events** (array) - Required - List of events to filter on.
- **type** (string) - Required - Type of event (e.g., 'contract_call').
- **contract_identifier** (string) - Required - Identifier of the contract.
- **function_name** (string) - Required - Name of the function.
- **action** (object) - Required - The action to perform when the chainhook is triggered.
- **type** (string) - Required - Type of action (e.g., 'http_post').
- **url** (string) - Required - The URL to send the webhook to.
- **options** (object) - Optional - Additional configuration options.
- **decode_clarity_values** (boolean) - Optional - Whether to decode Clarity values.
- **enable_on_registration** (boolean) - Optional - Whether to enable the chainhook upon registration.
### Request Example
```typescript
import { ChainhooksClient, CHAINHOOKS_BASE_URL } from '@hirosystems/chainhooks-client';
const client = new ChainhooksClient({
baseUrl: CHAINHOOKS_BASE_URL.testnet, // or CHAINHOOKS_BASE_URL.mainnet
apiKey: process.env.HIRO_API_KEY!,
});
const chainhook = await client.registerChainhook({
version: '1',
name: 'my-first-chainhook',
chain: 'stacks',
network: 'testnet',
filters: {
events: [
{
type: 'contract_call',
contract_identifier: 'SP...XYZ.counter',
function_name: 'increment',
},
],
},
action: {
type: 'http_post',
url: 'https://example.com/webhooks',
},
options: {
decode_clarity_values: true,
enable_on_registration: true,
},
});
console.log('Chainhooks created:', chainhook.uuid);
```
### Response
#### Success Response (200)
Returns the registered chainhook object, including its unique UUID.
- **uuid** (string) - The unique identifier of the created chainhook.
```
--------------------------------
### Get Stacks Node Info
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-node-rpc-api/usage.mdx
Make a GET request to the /v2/info endpoint to retrieve information about the Stacks node. Ensure the Accept header is set to application/json.
```console
https://api.hiro.so/v2/info
```
```terminal
$ curl -L 'https://api.hiro.so/v2/info' \
-H 'Accept: application/json'
```
--------------------------------
### Configure datadir in bitcoin.conf
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/resources/guides/sync-a-bitcoin-node.mdx
Set the data directory for your Bitcoin node in the bitcoin.conf file. Ensure the specified directory has sufficient storage space.
```bash
datadir=/Volumes/SSD/bitcoin-data/
```
--------------------------------
### Get details for multiple transactions
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/transactions/details-for-transactions.mdx
This endpoint retrieves detailed information for a list of transactions. You can specify multiple transaction IDs to get their respective details in a single request.
```APIDOC
## GET /extended/v1/tx/multiple
### Description
Retrieves details for a list of transactions.
### Method
GET
### Endpoint
/extended/v1/tx/multiple
### Query Parameters
- **tx_ids** (string) - Required - A comma-separated list of transaction IDs for which to retrieve details.
### Response
#### Success Response (200)
- **data** (array) - An array of transaction detail objects.
- **tx_id** (string) - The unique identifier of the transaction.
- **block_hash** (string) - The hash of the block in which the transaction was included.
- **block_height** (integer) - The height of the block in which the transaction was included.
- **tx_index** (integer) - The index of the transaction within its block.
- **sender** (string) - The address of the transaction sender.
- **recipient** (string) - The address of the transaction recipient.
- **amount** (string) - The amount transferred in the transaction (in STX, as a string representing a large integer).
- **fee** (string) - The transaction fee (in STX, as a string representing a large integer).
- **nonce** (integer) - The nonce of the transaction.
- **timestamp** (integer) - The Unix timestamp of the block inclusion.
- **memo** (string) - The memo associated with the transaction (if any).
- **status** (string) - The status of the transaction (e.g., "success", "failed").
- **contract_call** (object) - Details about a contract call, if applicable.
- **contract_id** (string) - The ID of the contract.
- **function_name** (string) - The name of the function called.
- **function_args** (array) - An array of arguments passed to the function.
- **token_transfer** (object) - Details about a token transfer, if applicable.
- **asset_contract_id** (string) - The ID of the asset contract.
- **asset_name** (string) - The name of the asset.
- **amount** (string) - The amount of tokens transferred.
- **recipient** (string) - The recipient of the tokens.
- **sender** (string) - The sender of the tokens.
#### Response Example
```json
{
"data": [
{
"tx_id": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"block_hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
"block_height": 12345,
"tx_index": 0,
"sender": "SP1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF",
"recipient": "SP000000000000000000002Q6W42",
"amount": "1000000",
"fee": "1000",
"nonce": 1,
"timestamp": 1678886400,
"memo": "",
"status": "success",
"contract_call": null,
"token_transfer": {
"asset_contract_id": "SP000000000000000000002Q6W42",
"asset_name": "STX",
"amount": "1000000",
"recipient": "SP1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF",
"sender": "SP1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF"
}
}
]
}
```
```
--------------------------------
### RPC Request with API Key Authentication
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-node-rpc-api/usage.mdx
This example shows how to authenticate your RPC requests by including your API key in the `x-api-key` header. This is recommended for higher rate limits.
```APIDOC
## GET /v2/info with Authentication
### Description
Retrieves general information about the Stacks node, authenticated with an API key.
### Method
GET
### Endpoint
/v2/info
### Parameters
#### Request Headers
- **Accept** (string) - Required - `application/json`
- **x-api-key** (string) - Required - Your Hiro API key
### Request Example
```bash
curl -L 'https://api.hiro.so/v2/info' \
-H 'Accept: application/json' \
-H 'x-api-key: $HIRO_API_KEY'
```
```
--------------------------------
### Monitor Stacks node synchronization logs
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/resources/guides/sync-a-stacks-node.mdx
View the logs for the Stacks node to monitor its synchronization progress. For networks other than 'mocknet', initial header download may take several minutes, during which the `/v2/info` endpoints will not provide data.
```bash
./manage.sh -n -a logs
```
--------------------------------
### Get a Chainhook
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/chainhooks-api/reference/chainhooks/get-chainhook.mdx
Retrieves a chainhook by its UUID.
```APIDOC
## GET /me/{uuid}
### Description
Retrieves a chainhook by its UUID.
### Method
GET
### Endpoint
/me/{uuid}
### Parameters
#### Path Parameters
- **uuid** (string) - Required - The unique identifier of the chainhook.
```
--------------------------------
### CodeTabs with different languages and annotations
Source: https://github.com/hirosystems/docs/blob/main/content/_hidden/docskit.mdx
Demonstrates using the CodeTabs component with different programming languages (Clarity and Solidity) and applying annotations like !mark within each tab.
```clarity
;; !mark[/increment/mg]
(define-data-var count uint u0)
(define-public (increment)
(begin
(var-set count (+ (var-get count) u1))
(ok (var-get count)) ;; !mark
)
)
```
```solidity
// !mark[/add/mg]
uint256 constant TOO_BIG = 10;
uint256 count = 0;
function add(uint256 amount) public returns (uint256) {
uint256 newCount = count + amount;
if (newCount <= TOO_BIG) {
count = newCount;
return count;
}
revert("Amount too large"); // !mark
}
```
--------------------------------
### Get Sortitions
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-node-rpc-api/reference/sortitions/get-sortitions.mdx
Retrieves information about sortitions from the burnchain.
```APIDOC
## GET /v3/sortitions
### Description
Retrieves information about sortitions from the burnchain.
### Method
GET
### Endpoint
/v3/sortitions
```
--------------------------------
### Chainhooks Client Configuration with API Key
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/tools/chainhooks/(chainhook-sdk)/introduction.mdx
Illustrates how to configure the Chainhooks client with an API key, emphasizing secure storage using environment variables.
```APIDOC
## Configure Chainhooks Client with API Key
### Description
This example shows the essential step of configuring the `ChainhooksClient` with your API key. It highlights the importance of securely managing your API key, recommending the use of environment variables to prevent exposure in your codebase.
### Method
`new ChainhooksClient(options)`
### Parameters
#### Request Body
- **baseUrl** (string) - Required - The base URL for the Chainhooks API (e.g., `CHAINHOOKS_BASE_URL.testnet`).
- **apiKey** (string) - Required - Your API key obtained from the Hiro platform. It is strongly recommended to load this from environment variables.
### Request Example
```typescript
const client = new ChainhooksClient({
baseUrl: CHAINHOOKS_BASE_URL.testnet,
apiKey: process.env.HIRO_API_KEY!,
});
```
### Warning
Never commit API keys to version control. Always use environment variables or secure secret management.
```
--------------------------------
### Get Fungible Tokens
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/token-metadata-api/reference/tokens/fungible-tokens.mdx
Retrieves information about fungible tokens.
```APIDOC
## GET /metadata/v1/ft
### Description
Retrieves information about fungible tokens.
### Method
GET
### Endpoint
/metadata/v1/ft
```
--------------------------------
### Request with API Key Authentication
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/token-metadata-api/usage.mdx
This example demonstrates how to authenticate your requests to the Token Metadata API using an API key. Replace `$HIRO_API_KEY` with your actual secret API key.
```APIDOC
## Authenticated Request
### Description
Making a request to the Token Metadata API with API key authentication.
### Method
GET
### Endpoint
`https://api.hiro.so/metadata/v1/ft`
### Parameters
#### Headers
- **Accept**: `application/json` (Required)
- **x-api-key**: `$HIRO_API_KEY` (Required) - Your secret API key.
### Request Example
```bash
curl -L 'https://api.hiro.so/metadata/v1/ft' \
-H 'Accept: application/json' \
-H 'x-api-key: $HIRO_API_KEY'
```
```
--------------------------------
### MDX Code Block Annotations
Source: https://github.com/hirosystems/docs/blob/main/README.md
Demonstrates various annotation syntaxes for code blocks in MDX, including highlighting, diffing, and collapsing lines.
```mdx
```ts
// !mark[3:5] Highlight lines 3-5
// !mark[/regex/] Highlight pattern
// !diff + Addition
// !diff - Removal
// !collapse[3:5] Collapse lines
```
```
--------------------------------
### Get All Names
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/names/names.mdx
Retrieves a list of all names known to the node.
```APIDOC
## GET /v1/names/
### Description
Retrieves a list of all names known to the node.
### Method
GET
### Endpoint
/v1/names/
```
--------------------------------
### Get Chainhook Status
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/platform-api/reference/chainhooks/status.mdx
Retrieves the status of a specific chainhook.
```APIDOC
## GET /v1/ext/{apiKey}/chainhooks/{chainhookUuid}/status
### Description
Retrieves the status of a specific chainhook.
### Method
GET
### Endpoint
/v1/ext/{apiKey}/chainhooks/{chainhookUuid}/status
### Parameters
#### Path Parameters
- **apiKey** (string) - Required - Your API key.
- **chainhookUuid** (string) - Required - The UUID of the chainhook.
### Response
#### Success Response (200)
- **status** (string) - The status of the chainhook (e.g., "active", "inactive", "error").
- **last_processed_block** (object) - Information about the last processed block.
- **height** (integer) - The height of the last processed block.
- **hash** (string) - The hash of the last processed block.
- **timestamp** (string) - The timestamp of the last processed block.
#### Response Example
```json
{
"status": "active",
"last_processed_block": {
"height": 123456,
"hash": "0xabc123...",
"timestamp": "2023-10-27T10:00:00Z"
}
}
```
```
--------------------------------
### Register a Chainhook
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/chainhooks-api/usage.mdx
Example of a POST request to register a new chainhook. Ensure `Content-Type` is set to `application/json` and include your API key.
```bash
curl -X POST https://api.testnet.hiro.so/chainhooks/v1/me/ \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "my-chainhook",
"version": "1",
"chain": "stacks",
"network": "testnet",
"filters": {
"events": [{
"type": "stx_transfer",
"sender": "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM"
}]
},
"action": {
"type": "http_post",
"url": "https://example.com/webhooks"
}
}'
```
--------------------------------
### Get all chainhooks
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/chainhooks-api/reference/chainhooks/get-chainhooks.mdx
Returns all chainhooks registered by the current user.
```APIDOC
## GET /me/
### Description
Returns all chainhooks registered by the current user.
### Method
GET
### Endpoint
/me/
```
--------------------------------
### Fetch Bitcoin Service Headers
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/resources/guides/response-headers.mdx
Example of fetching inscription data and logging the response. This code snippet shows the Bitcoin-specific rate limit headers that are returned.
```typescript
// Example: Fetching inscription data
const response = await fetch('https://api.hiro.so/ordinals/v1/inscriptions', {
headers: { 'x-api-key': apiKey }
});
console.log(response)
// New headers in response:
// x-ratelimit-cost-bitcoin: 1
// x-ratelimit-limit-bitcoin-minute: 500
// x-ratelimit-remaining-bitcoin-minute: 499
```
--------------------------------
### Get Constant Value
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-node-rpc-api/reference/smart-contracts/constants.mdx
Fetches the value of a constant from a smart contract.
```APIDOC
## GET /v2/constant_val/{contract_address}/{contract_name}/{constant_name}
### Description
Retrieves the value of a constant within a specified smart contract.
### Method
GET
### Endpoint
/v2/constant_val/{contract_address}/{contract_name}/{constant_name}
### Parameters
#### Path Parameters
- **contract_address** (string) - Required - The address of the smart contract.
- **contract_name** (string) - Required - The name of the smart contract.
- **constant_name** (string) - Required - The name of the constant whose value is to be retrieved.
### Response
#### Success Response (200)
- **data** (object) - The value of the constant.
- **data** (any) - The actual value of the constant. The type depends on the constant's definition.
#### Response Example
```json
{
"data": {
"data": "some_value"
}
}
```
```
--------------------------------
### Fetch API Response Headers
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/resources/guides/response-headers.mdx
Example of fetching API response headers using curl. This demonstrates how to retrieve all response headers, including rate limit information.
```bash
$ curl -I https://api.hiro.so/extended/v1/info -H 'x-api-key: your-api-key'
```
--------------------------------
### Get Transaction Events
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/transactions/transaction-events.mdx
Fetches all events emitted by a specific transaction.
```APIDOC
## GET /extended/v1/tx/events
### Description
Retrieves all events associated with a specific transaction.
### Method
GET
### Endpoint
/extended/v1/tx/events
### Query Parameters
- **tx_id** (string) - Required - The ID of the transaction for which to retrieve events.
```
--------------------------------
### Get Recent Transactions
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/transactions/recent-transactions.mdx
Fetches a list of the most recently mined transactions.
```APIDOC
## GET /extended/v1/tx/
### Description
Retrieves all recently mined transactions.
### Method
GET
### Endpoint
/extended/v1/tx/
```
--------------------------------
### Request with API Key Authentication
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/usage.mdx
This example shows how to authenticate your requests to the Stacks API using an API key. Replace `$HIRO_API_KEY` with your actual secret API key.
```APIDOC
## Request with API Key Authentication
### Description
This example shows how to authenticate your requests to the Stacks API using an API key. Replace `$HIRO_API_KEY` with your actual secret API key.
### Method
GET
### Endpoint
https://api.hiro.so/extended
### Parameters
#### Request Headers
- **Accept** (string) - Required - Specifies the desired response format, typically 'application/json'.
- **x-api-key** (string) - Required - Your secret API key for authentication.
### Request Example
```bash
curl -L 'https://api.hiro.so/extended' \
-H 'Accept: application/json' \
-H 'x-api-key: $HIRO_API_KEY'
```
### Response
#### Success Response (200)
- **body** (object) - The response body containing the requested data.
#### Response Example
```json
{
"example": "response body"
}
```
```
--------------------------------
### Fetch Chainhooks with Platform API
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/platform-api/index.mdx
Use this command to retrieve a list of all chainhooks associated with your API key. Ensure you replace `{apiKey}` with your actual API key.
```bash
$ curl -L 'https://api.platform.hiro.so/v1/ext/{apiKey}/chainhooks' -H 'Accept: application/json'
```
--------------------------------
### Get Name Subdomains
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/names/name-subdomains.mdx
Fetches a list of subdomains for a specified name.
```APIDOC
## GET /v1/names/{name}/subdomains
### Description
Retrieves the list of subdomains for a specific name.
### Method
GET
### Endpoint
/v1/names/{name}/subdomains
### Parameters
#### Path Parameters
- **name** (string) - Required - The name for which to retrieve subdomains.
### Response
#### Success Response (200)
- **subdomains** (array) - A list of subdomain strings.
```
--------------------------------
### Get STX Supply
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/info/total-and-unlocked-stx-supply.mdx
Retrieves the total and unlocked STX supply.
```APIDOC
## GET /extended/v1/stx_supply/
### Description
Retrieves the total and unlocked STX supply.
### Method
GET
### Endpoint
/extended/v1/stx_supply/
### Response
#### Success Response (200)
- **total_stx** (string) - The total STX supply.
- **unlocked_stx** (string) - The unlocked STX supply.
#### Response Example
{
"total_stx": "1840000000000000000",
"unlocked_stx": "1200000000000000000"
}
```
--------------------------------
### Fetch Stacks Service Headers
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/resources/guides/response-headers.mdx
Example of fetching Stacks account info and logging the response. This code snippet highlights the new Stacks-specific rate limit headers returned by the API.
```typescript
// Example: Fetching Stacks account info
const response = await fetch('https://api.hiro.so/extended/v1/address/SP318Q55DEKHRXJK696033DQN5C54D9K2EE6DHRWP/assets', {
headers: { 'x-api-key': apiKey }
});
console.log(response)
// New headers in response:
// x-ratelimit-cost-stacks: 1 // !mark
// x-ratelimit-limit-stacks-minute: 500
// x-ratelimit-remaining-stacks-minute: 499
```
--------------------------------
### Get Recent Blocks
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/blocks/recent-blocks.mdx
Fetches a list of recently mined blocks.
```APIDOC
## GET /extended/v1/block/
### Description
Retrieves a list of recently mined blocks.
### Method
GET
### Endpoint
/extended/v1/block/
```
--------------------------------
### Get signer in PoX cycle
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/proof-of-transfer/signer-in-cycle.mdx
Retrieves details for a signer in a PoX cycle.
```APIDOC
## GET /extended/v2/pox/cycles/{cycle_number}/signers/{signer_key}
### Description
Retrieves details for a signer in a PoX cycle.
### Method
GET
### Endpoint
/extended/v2/pox/cycles/{cycle_number}/signers/{signer_key}
### Parameters
#### Path Parameters
- **cycle_number** (integer) - Required - The cycle number to query.
- **signer_key** (string) - Required - The public key of the signer.
### Response
#### Success Response (200)
- **total_staked** (integer) - The total amount staked by the signer in this cycle.
- **total_earned** (integer) - The total amount earned by the signer in this cycle.
- **total_delegated** (integer) - The total amount delegated by the signer in this cycle.
- **total_delegators** (integer) - The total number of delegators for the signer in this cycle.
- **unlock_height** (integer) - The unlock height for the signer's stake.
- **delegation_total_staked** (integer) - The total amount staked by delegators.
- **delegation_total_earned** (integer) - The total amount earned by delegators.
- **delegation_total_delegated** (integer) - The total amount delegated by delegators.
- **delegation_total_delegators** (integer) - The total number of delegators.
- **delegation_unlock_height** (integer) - The unlock height for the delegators' stake.
- **delegated_to_by** (array) - A list of addresses that have delegated to this signer.
- **address** (string) - The address of the delegator.
- **amount_staked** (integer) - The amount staked by the delegator.
- **amount_earned** (integer) - The amount earned by the delegator.
- **amount_delegated** (integer) - The amount delegated by the delegator.
- **unlock_height** (integer) - The unlock height for the delegator's stake.
- **delegated_to** (array) - A list of addresses to which this signer has delegated.
- **address** (string) - The address to which the signer delegated.
- **amount_staked** (integer) - The amount staked by the signer to this address.
- **amount_earned** (integer) - The amount earned by the signer from this delegation.
- **amount_delegated** (integer) - The amount delegated by the signer to this address.
- **unlock_height** (integer) - The unlock height for this delegation.
### Response Example
{
"total_staked": 100000000000000,
"total_earned": 5000000000000,
"total_delegated": 20000000000000,
"total_delegators": 10,
"unlock_height": 1000,
"delegation_total_staked": 50000000000000,
"delegation_total_earned": 2000000000000,
"delegation_total_delegated": 10000000000000,
"delegation_total_delegators": 5,
"delegation_unlock_height": 1000,
"delegated_to_by": [
{
"address": "SP1234567890abcdefghijklmnopqrstuvwxyz0987654321",
"amount_staked": 10000000000000,
"amount_earned": 500000000000,
"amount_delegated": 5000000000000,
"unlock_height": 1000
}
],
"delegated_to": [
{
"address": "SP1234567890abcdefghijklmnopqrstuvwxyz0987654321",
"amount_staked": 5000000000000,
"amount_earned": 200000000000,
"amount_delegated": 5000000000000,
"unlock_height": 1000
}
]
}
```
--------------------------------
### Make a Basic Request to Token Metadata API
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/token-metadata-api/usage.mdx
Example of a basic curl request to the Token Metadata API to fetch fungible tokens (ft). Ensure the Accept header is set to application/json.
```curl
$ curl -L 'https://api.hiro.so/metadata/v1/ft' \
-H 'Accept: application/json'
```
--------------------------------
### Get Specific Chainhook
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/tools/chainhooks/(chainhook-sdk)/fetch.mdx
Retrieve a specific chainhook by its unique identifier (UUID).
```APIDOC
## getChainhook
Retrieve a specific chainhook by UUID.
### Method Signature
`client.getChainhook(uuid: string): Promise;`
### Parameters
- **uuid** (string) - Required - The unique identifier (UUID) of the chainhook to retrieve.
### Request Example
```typescript
const chainhook = await client.getChainhook('be4ab3ed-b606-4fe0-97c4-6c0b1ac9b185');
```
### Response Example (Success)
```json
{
"id": "be4ab3ed-b606-4fe0-97c4-6c0b1ac9b185",
"created_at": "2023-01-01T12:00:00Z",
"updated_at": "2023-01-01T12:00:00Z",
"name": "My First Chainhook",
"url": "https://example.com/chainhook",
"event_type": "block_connected",
"filter": {},
"authentication": null
}
```
```
--------------------------------
### Fetch Fungible Token Metadata
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/token-metadata-api/index.mdx
Use this command to fetch metadata for fungible tokens. Ensure you include the 'Accept: application/json' header for a JSON response.
```bash
curl -L 'https://api.hiro.so/metadata/v1/ft' -H 'Accept: application/json'
```
--------------------------------
### Get block by hash
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-blockchain-api/reference/blocks/block-by-hash.mdx
Fetches the details of a specific block using its hash.
```APIDOC
## GET /extended/v1/block/{hash}
### Description
Retrieves block details of a specific block for a given chain height.
### Method
GET
### Endpoint
/extended/v1/block/{hash}
### Parameters
#### Path Parameters
- **hash** (string) - Required - The hash of the block to retrieve.
```
--------------------------------
### List an Asset in Clarity
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/resources/guides/build-a-decentralized-kickstarter.mdx
Create a public function to list an asset. It verifies contract whitelisting, expiry, price, and transfers NFT ownership to the marketplace contract before storing the listing details.
```clarity
(define-public (list-asset
(nft-asset-contract )
(nft-asset {
taker: (optional principal),
token-id: uint,
expiry: uint,
price: uint,
payment-asset-contract: (optional principal)
})
)
(let ((listing-id (var-get listing-nonce)))
;; Verify that the contract of this asset is whitelisted
(asserts! (is-whitelisted (contract-of nft-asset-contract)) ERR_ASSET_CONTRACT_NOT_WHITELISTED)
;; Verify that the asset is not expired
(asserts! (> (get expiry nft-asset) block-height) ERR_EXPIRY_IN_PAST)
;; Verify that the asset price is greater than zero
(asserts! (> (get price nft-asset) u0) ERR_PRICE_ZERO)
;; Verify that the contract of the payment is whitelisted
(asserts! (match (get payment-asset-contract nft-asset)
payment-asset
(is-whitelisted payment-asset)
true
) ERR_PAYMENT_CONTRACT_NOT_WHITELISTED)
;; Transfer the NFT ownership to this contract's principal
(try! (transfer-nft
nft-asset-contract
(get token-id nft-asset)
tx-sender
(as-contract tx-sender)
))
;; List the NFT in the listings map
(map-set listings listing-id (merge
{ maker: tx-sender, nft-asset-contract: (contract-of nft-asset-contract) }
nft-asset
))
;; Increment the nonce to use for the next unique listing ID
(var-set listing-nonce (+ listing-id u1))
;; Return the created listing ID
(ok listing-id)
)
)
```
--------------------------------
### Get Trait Implementation Details
Source: https://github.com/hirosystems/docs/blob/main/content/docs/en/apis/stacks-node-rpc-api/reference/smart-contracts/traits.mdx
Checks if a specific trait is implemented by a contract.
```APIDOC
## GET /v2/traits/{contract_address}/{contract_name}/{trait_contract_address}/{trait_contract_name}/{trait_name}
### Description
Determine whether or not a specified trait is implemented (either explicitly or implicitly) within a given contract.
### Method
GET
### Endpoint
/v2/traits/{contract_address}/{contract_name}/{trait_contract_address}/{trait_contract_name}/{trait_name}
### Parameters
#### Path Parameters
- **contract_address** (string) - Required - The address of the contract.
- **contract_name** (string) - Required - The name of the contract.
- **trait_contract_address** (string) - Required - The address of the trait contract.
- **trait_contract_name** (string) - Required - The name of the trait contract.
- **trait_name** (string) - Required - The name of the trait.
### Response
#### Success Response (200)
- **implements** (boolean) - Indicates if the trait is implemented.
```