diff --git a/app/global.css b/app/global.css index d9566f330..849f09e2a 100644 --- a/app/global.css +++ b/app/global.css @@ -306,7 +306,7 @@ } /* kill the vertical guide on every block rendered by Code Hike */ - /* pre[data-ch="true"] .flex { + pre[data-ch="true"] .flex { border-left: none !important; - } */ + } } diff --git a/components/openapi/api-playground/index.tsx b/components/openapi/api-playground/index.tsx index 50da9f2eb..322dd0bd9 100644 --- a/components/openapi/api-playground/index.tsx +++ b/components/openapi/api-playground/index.tsx @@ -47,11 +47,43 @@ export function APIPlayground({ }: APIPlaygroundProps) { const [loading, setLoading] = useState(false); const [response, setResponse] = useState(null); - const [formData, setFormData] = useState>({}); + + const getInitialFormData = () => { + const initialData: Record = {}; + + // Add example values for parameters + if (operation.parameters) { + for (const param of operation.parameters) { + if (param.example !== undefined) { + initialData[param.name] = param.example.toString(); + } + } + } + + // Add example values for request body + if (operation.requestBody) { + const bodySchema = + operation.requestBody.content?.["application/json"]?.schema; + if (bodySchema?.type === "object" && bodySchema.properties) { + const exampleBody = + operation.requestBody.content?.["application/json"]?.example; + if (exampleBody && typeof exampleBody === "object") { + for (const [key, value] of Object.entries(exampleBody)) { + initialData[`body.${key}`] = + typeof value === "string" ? value : JSON.stringify(value); + } + } + } + } + + return initialData; + }; + + const [formData, setFormData] = + useState>(getInitialFormData()); const [openSections, setOpenSections] = useState([]); const formRef = useRef(null); - // Group parameters by type const pathParams = operation.parameters?.filter((p) => p.in === "path") || []; const queryParams = operation.parameters?.filter((p) => p.in === "query") || []; @@ -59,10 +91,9 @@ export function APIPlayground({ operation.parameters?.filter((p) => p.in === "header") || []; const hasRequestBody = !!operation.requestBody; - // Build display URL (without base URL) const buildDisplayUrl = () => { let path = operation.path; - // Replace path parameters + if (operation.parameters) { for (const param of operation.parameters) { if (param.in === "path" && formData[param.name]) { @@ -71,9 +102,9 @@ export function APIPlayground({ } } - // Add query parameters const queryParams = operation.parameters?.filter( - (p) => p.in === "query" && formData[p.name] + (p) => + p.in === "query" && formData[p.name] && formData[p.name].trim() !== "", ); const queryString = queryParams && queryParams.length > 0 @@ -85,7 +116,6 @@ export function APIPlayground({ return `${path}${queryString}`; }; - // Build full URL (with base URL for requests) const buildUrl = () => { const displayUrl = buildDisplayUrl(); return `${baseUrl || "https://api.hiro.so"}${displayUrl}`; @@ -99,34 +129,30 @@ export function APIPlayground({ headerParams.length > 0 || hasRequestBody; - // Check if all required fields are filled const isFormValid = () => { // Check required path parameters if (pathParams.some((p) => p.required && !formData[p.name])) { return false; } - // Check required query parameters if (queryParams.some((p) => p.required && !formData[p.name])) { return false; } - // Check required header parameters if (headerParams.some((p) => p.required && !formData[p.name])) { return false; } - // Check required body fields if (operation.requestBody?.required) { const bodySchema = operation.requestBody.content?.["application/json"]?.schema; if (bodySchema?.type === "object" && bodySchema.properties) { const hasRequiredBodyFields = Object.entries( - bodySchema.properties + bodySchema.properties, ).some( ([propName, propSchema]: [string, any]) => bodySchema.required?.includes(propName) && - !formData[`body.${propName}`] + !formData[`body.${propName}`], ); if (hasRequiredBodyFields) { return false; @@ -146,17 +172,16 @@ export function APIPlayground({ if (headerParams.some((p) => p.required && !formData[p.name])) requiredSections.push("header"); - // Check for required body fields if (operation.requestBody?.required) { const bodySchema = operation.requestBody.content?.["application/json"]?.schema; if (bodySchema?.type === "object" && bodySchema.properties) { const hasRequiredBodyFields = Object.entries( - bodySchema.properties + bodySchema.properties, ).some( ([propName, propSchema]: [string, any]) => bodySchema.required?.includes(propName) && - !formData[`body.${propName}`] + !formData[`body.${propName}`], ); if (hasRequiredBodyFields) { requiredSections.push("body"); @@ -169,7 +194,6 @@ export function APIPlayground({ return; } - // Build request body from individual fields if needed let finalFormData = { ...formData }; if (operation.requestBody) { const bodySchema = @@ -178,7 +202,7 @@ export function APIPlayground({ const bodyObject: Record = {}; for (const [propName, propSchema] of Object.entries( - bodySchema.properties + bodySchema.properties, ) as [string, any][]) { const fieldValue = formData[`body.${propName}`]; if (fieldValue !== undefined && fieldValue !== "") { @@ -265,7 +289,6 @@ export function APIPlayground({ } } - // Submit the request handleSubmit(finalFormData); }; @@ -280,7 +303,7 @@ export function APIPlayground({ { proxyUrl: playgroundOptions?.proxyUrl, auth: playgroundOptions?.defaultAuth, - } + }, ); setResponse(result); } catch (error) { @@ -298,7 +321,7 @@ export function APIPlayground({
@@ -338,7 +361,7 @@ export function APIPlayground({ open={openSections.includes("path")} onOpenChange={(open) => { setOpenSections((prev) => - open ? [...prev, "path"] : prev.filter((s) => s !== "path") + open ? [...prev, "path"] : prev.filter((s) => s !== "path"), ); }} > @@ -370,7 +393,7 @@ export function APIPlayground({ open={openSections.includes("query")} onOpenChange={(open) => { setOpenSections((prev) => - open ? [...prev, "query"] : prev.filter((s) => s !== "query") + open ? [...prev, "query"] : prev.filter((s) => s !== "query"), ); }} > @@ -404,7 +427,7 @@ export function APIPlayground({ setOpenSections((prev) => open ? [...prev, "header"] - : prev.filter((s) => s !== "header") + : prev.filter((s) => s !== "header"), ); }} > @@ -434,7 +457,7 @@ export function APIPlayground({ open={openSections.includes("body")} onOpenChange={(open) => { setOpenSections((prev) => - open ? [...prev, "body"] : prev.filter((s) => s !== "body") + open ? [...prev, "body"] : prev.filter((s) => s !== "body"), ); }} > @@ -469,7 +492,7 @@ export function APIPlayground({ "inline-flex items-center rounded border transition-colors font-fono text-xs px-1.5 py-0 h-5", response.status >= 200 && response.status < 300 ? "bg-[#e7f7e7] text-[#4B714D] border-[#c2ebc4] dark:bg-background dark:text-[#c2ebc4] dark:border-[#c2ebc4]" - : "bg-[#ffe7e7] text-[#8A4B4B] border-[#ffc2c2] dark:bg-background dark:text-[#ffc2c2] dark:border-[#ffc2c2]" + : "bg-[#ffe7e7] text-[#8A4B4B] border-[#ffc2c2] dark:bg-background dark:text-[#ffc2c2] dark:border-[#ffc2c2]", )} > {response.status} {response.statusText || ""} @@ -576,7 +599,7 @@ function MethodBadge({ method }: { method: string }) { {upperMethod} diff --git a/components/openapi/api-playground/request-builder.tsx b/components/openapi/api-playground/request-builder.tsx index c824ccd9b..af307a25a 100644 --- a/components/openapi/api-playground/request-builder.tsx +++ b/components/openapi/api-playground/request-builder.tsx @@ -280,6 +280,8 @@ export const RequestBuilder = forwardRef( hasError && "border-red-500", "font-fono" )} + disabled={false} + type="text" /> {hasError && ( diff --git a/components/openapi/api-playground/request-executor.tsx b/components/openapi/api-playground/request-executor.tsx index 751e17fe1..5ed42f401 100644 --- a/components/openapi/api-playground/request-executor.tsx +++ b/components/openapi/api-playground/request-executor.tsx @@ -51,7 +51,7 @@ export async function executeRequest( operation.parameters?.filter((p) => p.in === "query") || []; for (const param of queryParameters) { const value = formData[param.name]; - if (!value) continue; + if (!value || value.trim() === "") continue; if (clarityConversion && param.schema?.["x-clarity-type"]) { try { diff --git a/content/docs/apis/ordinals-api/index.mdx b/content/docs/apis/ordinals-api/index.mdx index c8dbb5ccf..8080666bb 100644 --- a/content/docs/apis/ordinals-api/index.mdx +++ b/content/docs/apis/ordinals-api/index.mdx @@ -2,6 +2,7 @@ title: Ordinals API sidebarTitle: Overview description: Fast, reliable data for Bitcoin ordinals and BRC-20 tokens via REST. +llm: false --- ## Overview @@ -26,4 +27,4 @@ For more usage examples, click [here](/apis/ordinals-api/usage). type: help ### Need help building with the Ordinals API? Reach out to us on the #ordinals channel on [Discord](https://stacks.chat/) under the Hiro Developer Tools section. There's also a [weekly office hours](https://www.addevent.com/event/kI22007085) call every Wednesday at 1pm ET. -::: \ No newline at end of file +::: diff --git a/content/docs/apis/platform-api/index.mdx b/content/docs/apis/platform-api/index.mdx index 582aed267..4d6acd3d4 100644 --- a/content/docs/apis/platform-api/index.mdx +++ b/content/docs/apis/platform-api/index.mdx @@ -2,6 +2,7 @@ title: Platform API sidebarTitle: Overview description: Programmatic access to devnet and chainhook management via REST. +llm: false --- ## Overview @@ -26,4 +27,4 @@ For more usage examples, click [here](/apis/platform-api/usage). type: help ### Need help building with the Platform API? Reach out to us on the #hiro-platform channel on [Discord](https://stacks.chat/) under the Hiro Developer Tools section. There's also a [weekly office hours](https://www.addevent.com/event/kI22007085) call every Wednesday at 1pm ET. -::: \ No newline at end of file +::: diff --git a/content/docs/apis/runes-api/index.mdx b/content/docs/apis/runes-api/index.mdx index f81e94cf9..ecfd90152 100644 --- a/content/docs/apis/runes-api/index.mdx +++ b/content/docs/apis/runes-api/index.mdx @@ -2,6 +2,7 @@ title: Runes API sidebarTitle: Overview description: Fast, reliable data for Bitcoin Runes via REST. +llm: false --- ## Overview @@ -26,4 +27,4 @@ For more usage examples, click [here](/apis/runes-api/usage). type: help ### Need help building with the Runes API? Reach out to us on the #ordinals channel on [Discord](https://stacks.chat/) under the Hiro Developer Tools section. There's also a [weekly office hours](https://www.addevent.com/event/kI22007085) call every Wednesday at 1pm ET. -::: \ No newline at end of file +::: diff --git a/content/docs/apis/signer-metrics-api/index.mdx b/content/docs/apis/signer-metrics-api/index.mdx index cd7a03888..c6c95b71a 100644 --- a/content/docs/apis/signer-metrics-api/index.mdx +++ b/content/docs/apis/signer-metrics-api/index.mdx @@ -2,6 +2,7 @@ title: Signer Metrics API sidebarTitle: Overview description: Monitor and analyze signer behavior on the Stacks network via REST. +llm: false --- ## Overview @@ -26,4 +27,4 @@ For more usage examples, click [here](/apis/signer-metrics-api/usage). type: help ### Need help building with the Signer Metrics API? Reach out to us on the #api channel on [Discord](https://stacks.chat/) under the Hiro Developer Tools section. There's also a [weekly office hours](https://www.addevent.com/event/kI22007085) call every Wednesday at 1pm ET. -::: \ No newline at end of file +::: diff --git a/content/docs/apis/stacks-blockchain-api/index.mdx b/content/docs/apis/stacks-blockchain-api/index.mdx index 149540156..29d05bd94 100644 --- a/content/docs/apis/stacks-blockchain-api/index.mdx +++ b/content/docs/apis/stacks-blockchain-api/index.mdx @@ -2,6 +2,7 @@ title: Stacks Blockchain API sidebarTitle: Overview description: Fast, reliable blockchain data for the Stacks ecosystem via REST. +llm: false --- ## Overview diff --git a/content/docs/apis/stacks-blockchain-api/reference/blocks/block-by-height-v3.mdx b/content/docs/apis/stacks-blockchain-api/reference/blocks/block-by-height-v3.mdx new file mode 100644 index 000000000..dc66333e9 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/blocks/block-by-height-v3.mdx @@ -0,0 +1,13 @@ +--- +title: Block by height (v3) +sidebarTitle: Block by height (v3) +description: Retrieves a block by its height using the v3 endpoint. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/blocks/meta.json b/content/docs/apis/stacks-blockchain-api/reference/blocks/meta.json index 267349366..58ece9e96 100644 --- a/content/docs/apis/stacks-blockchain-api/reference/blocks/meta.json +++ b/content/docs/apis/stacks-blockchain-api/reference/blocks/meta.json @@ -8,9 +8,11 @@ "recent-blocks", "block-by-hash", "block-by-height", + "block-by-height-v3", "block-by-burn-block-hash", "block-by-burn-block-height", - "block-proposal" + "block-proposal", + "upload-block" ], "defaultOpen": false } \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/blocks/upload-block.mdx b/content/docs/apis/stacks-blockchain-api/reference/blocks/upload-block.mdx new file mode 100644 index 000000000..819223568 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/blocks/upload-block.mdx @@ -0,0 +1,13 @@ +--- +title: Upload block +sidebarTitle: Upload block +description: Upload a block to the node. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/info/health.mdx b/content/docs/apis/stacks-blockchain-api/reference/info/health.mdx new file mode 100644 index 000000000..77c60de9e --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/info/health.mdx @@ -0,0 +1,13 @@ +--- +title: Health check +sidebarTitle: Health +description: Get health information about the node's synchronization status. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/info/meta.json b/content/docs/apis/stacks-blockchain-api/reference/info/meta.json index f553c6ac4..b69327268 100644 --- a/content/docs/apis/stacks-blockchain-api/reference/info/meta.json +++ b/content/docs/apis/stacks-blockchain-api/reference/info/meta.json @@ -3,6 +3,7 @@ "pages": [ "status", "core-api", + "health", "network-block-time", "network-given-block-time", "total-and-unlocked-stx-supply", diff --git a/content/docs/apis/stacks-blockchain-api/reference/nakamoto/meta.json b/content/docs/apis/stacks-blockchain-api/reference/nakamoto/meta.json index 1bcd2d42e..1d0fa3132 100644 --- a/content/docs/apis/stacks-blockchain-api/reference/nakamoto/meta.json +++ b/content/docs/apis/stacks-blockchain-api/reference/nakamoto/meta.json @@ -3,7 +3,9 @@ "pages": [ "nakamoto-block", "tenure-blocks", - "tenure-metadata" + "tenure-metadata", + "tenure-fork-info", + "tenure-tip" ], "defaultOpen": false } \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/nakamoto/tenure-fork-info.mdx b/content/docs/apis/stacks-blockchain-api/reference/nakamoto/tenure-fork-info.mdx new file mode 100644 index 000000000..c8118e120 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/nakamoto/tenure-fork-info.mdx @@ -0,0 +1,13 @@ +--- +title: Tenure fork info +sidebarTitle: Tenure fork info +description: Get information about tenure forks between two block IDs. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/nakamoto/tenure-tip.mdx b/content/docs/apis/stacks-blockchain-api/reference/nakamoto/tenure-tip.mdx new file mode 100644 index 000000000..6d81ba5f4 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/nakamoto/tenure-tip.mdx @@ -0,0 +1,13 @@ +--- +title: Tenure tip +sidebarTitle: Tenure tip +description: Get the tip block ID of the tenure associated with a given consensus hash. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/proof-of-transfer/meta.json b/content/docs/apis/stacks-blockchain-api/reference/proof-of-transfer/meta.json index 604341a99..5e54fd106 100644 --- a/content/docs/apis/stacks-blockchain-api/reference/proof-of-transfer/meta.json +++ b/content/docs/apis/stacks-blockchain-api/reference/proof-of-transfer/meta.json @@ -5,6 +5,7 @@ "cycle", "signers-in-cycle", "signer-in-cycle", + "signer-details", "stackers-for-signer-in-cycle", "pox-details", "stacker-set" diff --git a/content/docs/apis/stacks-blockchain-api/reference/proof-of-transfer/signer-details.mdx b/content/docs/apis/stacks-blockchain-api/reference/proof-of-transfer/signer-details.mdx new file mode 100644 index 000000000..a25bb1883 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/proof-of-transfer/signer-details.mdx @@ -0,0 +1,13 @@ +--- +title: Signer details +sidebarTitle: Signer details +description: Get signer information for a specific signer and cycle. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/constants.mdx b/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/constants.mdx index dc3c4b518..1dc393ab2 100644 --- a/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/constants.mdx +++ b/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/constants.mdx @@ -8,6 +8,6 @@ isRpc: true \ No newline at end of file +/> diff --git a/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/fast-read-only.mdx b/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/fast-read-only.mdx new file mode 100644 index 000000000..ad75b218f --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/fast-read-only.mdx @@ -0,0 +1,13 @@ +--- +title: Fast call read-only function +sidebarTitle: Fast call read-only +description: Call a read-only function on a smart contract without cost and memory tracking for faster execution. +full: true +isRpc: true +--- + + diff --git a/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/meta.json b/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/meta.json index 6a2f04274..856c9a5e1 100644 --- a/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/meta.json +++ b/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/meta.json @@ -8,10 +8,11 @@ "interface", "map-entry", "read-only", + "fast-read-only", "events", + "variable", "constants", "traits" ], "defaultOpen": false } - diff --git a/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/variable.mdx b/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/variable.mdx new file mode 100644 index 000000000..572c63c9e --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/smart-contracts/variable.mdx @@ -0,0 +1,13 @@ +--- +title: Get data variable +sidebarTitle: Data variable value +description: Get contract data variable +full: true +isRpc: true +--- + + diff --git a/content/docs/apis/stacks-blockchain-api/reference/sortitions/get-sortitions.mdx b/content/docs/apis/stacks-blockchain-api/reference/sortitions/get-sortitions.mdx new file mode 100644 index 000000000..1296304b9 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/sortitions/get-sortitions.mdx @@ -0,0 +1,13 @@ +--- +title: Get sortitions +sidebarTitle: Get sortitions +description: Retrieves information about sortitions from the burnchain. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/sortitions/latest-and-last-sortitions.mdx b/content/docs/apis/stacks-blockchain-api/reference/sortitions/latest-and-last-sortitions.mdx new file mode 100644 index 000000000..fd8041349 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/sortitions/latest-and-last-sortitions.mdx @@ -0,0 +1,13 @@ +--- +title: Latest and last sortitions +sidebarTitle: Latest and last sortitions +description: Retrieves information about the latest and last sortitions. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/sortitions/meta.json b/content/docs/apis/stacks-blockchain-api/reference/sortitions/meta.json new file mode 100644 index 000000000..c8f958f86 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/sortitions/meta.json @@ -0,0 +1,11 @@ +{ + "title": "Sortitions", + "pages": [ + "get-sortitions", + "sortition-by-burn-hash", + "sortition-by-burn-height", + "sortition-by-consensus-hash", + "latest-and-last-sortitions" + ], + "defaultOpen": false +} \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/sortitions/sortition-by-burn-hash.mdx b/content/docs/apis/stacks-blockchain-api/reference/sortitions/sortition-by-burn-hash.mdx new file mode 100644 index 000000000..9ec2ec0c5 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/sortitions/sortition-by-burn-hash.mdx @@ -0,0 +1,13 @@ +--- +title: Sortition by burn hash +sidebarTitle: Sortition by burn hash +description: Retrieves information about a sortition by its burn block hash. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/sortitions/sortition-by-burn-height.mdx b/content/docs/apis/stacks-blockchain-api/reference/sortitions/sortition-by-burn-height.mdx new file mode 100644 index 000000000..60c8aadd3 --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/sortitions/sortition-by-burn-height.mdx @@ -0,0 +1,13 @@ +--- +title: Sortition by burn height +sidebarTitle: Sortition by burn height +description: Retrieves information about a sortition by its burn block height. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/sortitions/sortition-by-consensus-hash.mdx b/content/docs/apis/stacks-blockchain-api/reference/sortitions/sortition-by-consensus-hash.mdx new file mode 100644 index 000000000..b671b1caa --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/sortitions/sortition-by-consensus-hash.mdx @@ -0,0 +1,13 @@ +--- +title: Sortition by consensus hash +sidebarTitle: Sortition by consensus hash +description: Retrieves information about a sortition by its consensus hash. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/stacks-blockchain-api/reference/transactions/meta.json b/content/docs/apis/stacks-blockchain-api/reference/transactions/meta.json index a8d562533..33d8ed70d 100644 --- a/content/docs/apis/stacks-blockchain-api/reference/transactions/meta.json +++ b/content/docs/apis/stacks-blockchain-api/reference/transactions/meta.json @@ -4,6 +4,7 @@ "recent-transactions", "get-transaction", "get-raw-transaction", + "transaction-details-v3", "address-transactions", "transactions-by-block", "events-for-an-address-transaction", diff --git a/content/docs/apis/stacks-blockchain-api/reference/transactions/transaction-details-v3.mdx b/content/docs/apis/stacks-blockchain-api/reference/transactions/transaction-details-v3.mdx new file mode 100644 index 000000000..37b8a6dca --- /dev/null +++ b/content/docs/apis/stacks-blockchain-api/reference/transactions/transaction-details-v3.mdx @@ -0,0 +1,13 @@ +--- +title: Transaction details (v3) +sidebarTitle: Transaction details (v3) +description: Get transaction details by transaction ID using the v3 endpoint. +full: true +isRpc: true +--- + + \ No newline at end of file diff --git a/content/docs/apis/token-metadata-api/index.mdx b/content/docs/apis/token-metadata-api/index.mdx index d55481e54..8e8585c21 100644 --- a/content/docs/apis/token-metadata-api/index.mdx +++ b/content/docs/apis/token-metadata-api/index.mdx @@ -2,6 +2,7 @@ title: Token Metadata API sidebarTitle: Overview description: Fast, reliable metadata for Stacks tokens via REST. +llm: false --- ## Overview diff --git a/content/docs/resources/clarity/reference/functions.mdx b/content/docs/resources/clarity/reference/functions.mdx index 3703debb9..be18b46c0 100644 --- a/content/docs/resources/clarity/reference/functions.mdx +++ b/content/docs/resources/clarity/reference/functions.mdx @@ -698,90 +698,6 @@ Clarity provides a comprehensive set of built-in functions for smart contract de (err u404))) ``` -### map [#map] - -`map` applies a function to each element of a list. - -**Signature** - -```clarity -(map func list1 list2...) -``` - -**Parameters** - -| Name | Type | Description | -|------|------|-------------| -| `func` | function | Function to apply | -| `list1`, `list2`, ... | `list` | Lists to map over | - -```clarity -(map + (list 1 2 3) (list 10 20 30)) ;; Returns (11 22 33) - -;; Double all values -(define-private (double (x uint)) - (* x u2)) - -(define-read-only (double-all (numbers (list 10 uint))) - (map double numbers)) -``` - -### filter [#filter] - -`filter` returns elements that satisfy a predicate. - -**Signature** - -```clarity -(filter func list) -``` - -**Parameters** - -| Name | Type | Description | -|------|------|-------------| -| `func` | function | Predicate function | -| `list` | `list` | List to filter | - -```clarity -(define-private (is-even (x uint)) - (is-eq (mod x u2) u0)) - -(filter is-even (list u1 u2 u3 u4)) ;; Returns (u2 u4) - -;; Filter active users -(define-read-only (get-active-users) - (filter is-active (var-get all-users))) -``` - -### fold [#fold] - -`fold` reduces a list to a single value. - -**Signature** - -```clarity -(fold func list initial-value) -``` - -**Parameters** - -| Name | Type | Description | -|------|------|-------------| -| `func` | function | Reducer function | -| `list` | `list` | List to reduce | -| `initial-value` | any | Starting value | - -```clarity -(fold + (list u1 u2 u3 u4) u0) ;; Returns u10 - -;; Sum balances -(define-private (add-balance (user principal) (total uint)) - (+ total (default-to u0 (map-get? balances user)))) - -(define-read-only (get-total-balance) - (fold add-balance (var-get users) u0)) -``` ### int-to-ascii [#int-to-ascii] @@ -988,6 +904,93 @@ Clarity provides a comprehensive set of built-in functions for smart contract de (buff-to-uint-le data)) ``` +## Iterators [#iterators] + +### map [#map] + +`map` applies a function to each element of a list. + +**Signature** + +```clarity +(map func list1 list2...) +``` + +**Parameters** + +| Name | Type | Description | +|------|------|-------------| +| `func` | function | Function to apply | +| `list1`, `list2`, ... | `list` | Lists to map over | + +```clarity +(map + (list 1 2 3) (list 10 20 30)) ;; Returns (11 22 33) + +;; Double all values +(define-private (double (x uint)) + (* x u2)) + +(define-read-only (double-all (numbers (list 10 uint))) + (map double numbers)) +``` + +### filter [#filter] + +`filter` returns elements that satisfy a predicate. + +**Signature** + +```clarity +(filter func list) +``` + +**Parameters** + +| Name | Type | Description | +|------|------|-------------| +| `func` | function | Predicate function | +| `list` | `list` | List to filter | + +```clarity +(define-private (is-even (x uint)) + (is-eq (mod x u2) u0)) + +(filter is-even (list u1 u2 u3 u4)) ;; Returns (u2 u4) + +;; Filter active users +(define-read-only (get-active-users) + (filter is-active (var-get all-users))) +``` + +### fold [#fold] + +`fold` reduces a list to a single value. + +**Signature** + +```clarity +(fold func list initial-value) +``` + +**Parameters** + +| Name | Type | Description | +|------|------|-------------| +| `func` | function | Reducer function | +| `list` | `list` | List to reduce | +| `initial-value` | any | Starting value | + +```clarity +(fold + (list u1 u2 u3 u4) u0) ;; Returns u10 + +;; Sum balances +(define-private (add-balance (user principal) (total uint)) + (+ total (default-to u0 (map-get? balances user)))) + +(define-read-only (get-total-balance) + (fold add-balance (var-get users) u0)) +``` + ## Data storage & variables [#data-storage-variables] ### define-constant [#define-constant] @@ -1380,370 +1383,514 @@ Clarity provides a comprehensive set of built-in functions for smart contract de }) ``` -## Control flow [#control-flow] +## Error handling [#error-handling] -### if [#if] +### ok [#ok] -`if` evaluates a condition and returns one of two values. +`ok` constructs a successful response value. **Signature** ```clarity -(if condition true-branch false-branch) +(ok value) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `condition` | `bool` | Condition to evaluate | -| `true-branch` | any | Value if true | -| `false-branch` | any | Value if false | +| `value` | any | Success value | ```clarity -(if (> u10 u5) - "Greater" - "Not greater") ;; Returns "Greater" +(ok u42) ;; Returns (ok u42) +(ok { status: "success", value: u100 }) -;; Conditional logic -(define-public (withdraw (amount uint)) - (let ((balance (get-balance tx-sender))) - (if (>= balance amount) - (begin - (map-set balances tx-sender (- balance amount)) - (ok amount)) - (err u1)))) +;; Success response +(define-public (deposit (amount uint)) + (begin + (map-set balances tx-sender + (+ (get-balance tx-sender) amount)) + (ok amount))) ``` -### match [#match] +### err [#err] -`match` performs pattern matching on optional and response types. +`err` constructs an error response value. **Signature** ```clarity -(match value - some-name some-branch - none-branch) +(err value) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `value` | optional/response | Value to match | -| `some-name` | symbol | Binding for some value | -| `some-branch` | expression | Expression if some | -| `none-branch` | expression | Expression if none | +| `value` | any | Error value | ```clarity -(match (map-get? balances tx-sender) - balance (ok balance) - (err u404)) - -;; Response matching -(match (ft-transfer? token u100 tx-sender recipient) - success (ok "Transfer successful") - error (err error)) +(err u404) ;; Returns (err u404) +(err { code: u500, message: "Internal error" }) -;; Nested matching -(define-read-only (get-user-name (user principal)) - (match (map-get? user-profiles user) - profile (match (get name profile) - name (ok name) - (err u1)) - (err u404))) +;; Error responses +(define-public (withdraw (amount uint)) + (let ((balance (get-balance tx-sender))) + (if (>= balance amount) + (ok amount) + (err u1)))) ;; Insufficient balance ``` -### begin [#begin] +### asserts! [#asserts] -`begin` executes multiple expressions in sequence. +`asserts!` checks a condition and exits with an error if false. **Signature** ```clarity -(begin expr1 expr2... last-expr) +(asserts! condition thrown-value) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `expr1`, `expr2`, ... | any | Expressions to execute | -| `last-expr` | any | Final expression (return value) | +| `condition` | `bool` | Condition to check | +| `thrown-value` | any | Value to return if false | ```clarity -(begin - (print "Starting") - (var-set counter u1) - (ok true)) - -;; Multiple operations -(define-public (initialize) +(define-public (transfer (amount uint) (recipient principal)) (begin - (asserts! (is-eq tx-sender contract-owner) (err u401)) - (var-set is-initialized true) - (map-set admins tx-sender true) - (print { event: "initialized", by: tx-sender }) + (asserts! (> amount u0) (err u1)) + (asserts! (not (is-eq tx-sender recipient)) (err u2)) + (asserts! (<= amount (get-balance tx-sender)) (err u3)) + (ok true))) + +;; Guard functions +(define-public (admin-only-function) + (begin + (asserts! (is-eq tx-sender contract-owner) (err u401)) + ;; Admin logic here (ok true))) ``` -### let [#let] +### try! [#try] -`let` creates local bindings for use in an expression. +`try!` attempts to unwrap a response, propagating any error. **Signature** ```clarity -(let ((name1 value1) (name2 value2)...) body) +(try! response) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `name` | symbol | Binding name | -| `value` | any | Value to bind | -| `body` | expression | Expression using bindings | +| `response` | response | Response to try | ```clarity -(let ((x 10) (y 20)) - (+ x y)) ;; Returns 30 +(try! (ok u42)) ;; Returns u42 +(try! (err u404)) ;; Propagates (err u404) -;; Complex calculations -(define-public (calculate-reward (days uint)) - (let ( - (balance (get-balance tx-sender)) - (rate u5) ;; 5% annual - (reward (/ (* balance rate days) u36500))) - (begin - (map-set rewards tx-sender reward) - (ok reward)))) +;; Chain operations +(define-public (complex-operation (amount uint)) + (begin + (try! (check-preconditions amount)) + (try! (process-payment amount)) + (try! (update-records)) + (ok true))) ``` -### asserts! [#asserts] +### unwrap! [#unwrap] -`asserts!` checks a condition and exits with an error if false. +`unwrap!` extracts the inner value from an optional or ok response. **Signature** ```clarity -(asserts! condition thrown-value) +(unwrap! optional-or-response thrown-value) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `condition` | `bool` | Condition to check | -| `thrown-value` | any | Value to return if false | +| `optional-or-response` | optional/response | Value to unwrap | +| `thrown-value` | any | Value if none/err | ```clarity -(define-public (transfer (amount uint) (recipient principal)) - (begin - (asserts! (> amount u0) (err u1)) - (asserts! (not (is-eq tx-sender recipient)) (err u2)) - (asserts! (<= amount (get-balance tx-sender)) (err u3)) - (ok true))) +(unwrap! (some u42) (err u1)) ;; Returns u42 +(unwrap! none (err u404)) ;; Throws (err u404) -;; Guard functions -(define-public (admin-only-function) - (begin - (asserts! (is-eq tx-sender contract-owner) (err u401)) - ;; Admin logic here - (ok true))) +;; Safe access +(define-public (transfer-from-map (recipient principal)) + (let ((amount (unwrap! (map-get? pending-transfers tx-sender) (err u404)))) + (try! (ft-transfer? token amount tx-sender recipient)) + (map-delete pending-transfers tx-sender) + (ok amount))) ``` -## Optional & response types [#optional-response-types] +### unwrap-err! [#unwrap-err] -### ok [#ok] +`unwrap-err!` extracts the error value from an err response. -`ok` constructs a successful response value. +**Signature** + +```clarity +(unwrap-err! response thrown-value) +``` + +**Parameters** + +| Name | Type | Description | +|------|------|-------------| +| `response` | response | Response to unwrap | +| `thrown-value` | any | Value if ok | + +```clarity +(unwrap-err! (err u404) u0) ;; Returns u404 +(unwrap-err! (ok u42) u0) ;; Returns u0 + +;; Error handling +(define-public (handle-error) + (let ((error-code (unwrap-err! (process-action) u0))) + (print { error: error-code }) + (ok error-code))) +``` + +### unwrap-panic [#unwrap-panic] + +`unwrap-panic` extracts a value or causes a runtime panic. **Signature** ```clarity -(ok value) +(unwrap-panic optional-or-response) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `value` | any | Success value | +| `optional-or-response` | optional/response | Value to unwrap | ```clarity -(ok u42) ;; Returns (ok u42) -(ok { status: "success", value: u100 }) +(unwrap-panic (some u42)) ;; Returns u42 +(unwrap-panic none) ;; Runtime panic -;; Success response -(define-public (deposit (amount uint)) - (begin - (map-set balances tx-sender - (+ (get-balance tx-sender) amount)) - (ok amount))) +;; Critical unwrap +(define-read-only (get-critical-value) + (unwrap-panic (map-get? critical-config "version"))) ``` -### err [#err] +### unwrap-err-panic [#unwrap-err-panic] -`err` constructs an error response value. +`unwrap-err-panic` extracts an error value or causes a runtime panic. **Signature** ```clarity -(err value) +(unwrap-err-panic response) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `value` | any | Error value | +| `response` | response | Response to unwrap | ```clarity -(err u404) ;; Returns (err u404) -(err { code: u500, message: "Internal error" }) +(unwrap-err-panic (err u404)) ;; Returns u404 +(unwrap-err-panic (ok u42)) ;; Runtime panic -;; Error responses -(define-public (withdraw (amount uint)) - (let ((balance (get-balance tx-sender))) - (if (>= balance amount) - (ok amount) - (err u1)))) ;; Insufficient balance +;; Force error +(define-read-only (get-error-code) + (unwrap-err-panic (always-fails))) ``` -### some [#some] +## Data helpers [#data-helpers] -`some` constructs an optional value that contains a value. +### default-to [#default-to] + +`default-to` returns a default value for none. **Signature** ```clarity -(some value) +(default-to default optional) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `value` | any | Value to wrap | +| `default` | any | Default value | +| `optional` | optional | Optional value | ```clarity -(some u42) ;; Returns (some u42) -(some "Hello") ;; Returns (some "Hello") +(default-to u0 (some u42)) ;; Returns u42 +(default-to u0 none) ;; Returns u0 -;; Return optional -(define-read-only (find-user (id uint)) - (if (map-get? users id) - (some (map-get? users id)) - none)) +;; Safe defaults +(define-read-only (get-balance-safe (user principal)) + (default-to u0 (map-get? balances user))) +``` + +### merge [#merge] + +`merge` combines two tuples, with the second overriding the first. + +**Signature** + +```clarity +(merge tuple1 tuple2) +``` + +**Parameters** + +| Name | Type | Description | +|------|------|-------------| +| `tuple1` | tuple | Base tuple | +| `tuple2` | tuple | Override tuple | + +```clarity +(merge { a: u1, b: u2 } { b: u3, c: u4 }) +;; Returns { a: u1, b: u3, c: u4 } + +;; Update record +(define-public (update-profile (updates { name: (optional (string-ascii 50)), age: (optional uint) })) + (let ((current (default-to { name: "", age: u0 } (map-get? profiles tx-sender)))) + (map-set profiles tx-sender (merge current updates)) + (ok true))) +``` + +### get [#get] + +`get` extracts a value from a tuple by key. + +**Signature** + +```clarity +(get key tuple) +``` + +**Parameters** + +| Name | Type | Description | +|------|------|-------------| +| `key` | symbol | Key to extract | +| `tuple` | tuple | Tuple to access | + +```clarity +(get balance { balance: u100, locked: u50 }) ;; Returns u100 + +;; Access nested data +(define-read-only (get-user-balance (user principal)) + (match (map-get? accounts user) + account (get balance account) + u0)) +``` + +### as-max-len? [#as-max-len] + +`as-max-len?` checks if a sequence fits within a maximum length. + +**Signature** + +```clarity +(as-max-len? sequence max-length) +``` + +**Parameters** + +| Name | Type | Description | +|------|------|-------------| +| `sequence` | sequence | Sequence to check | +| `max-length` | uint | Maximum allowed length | + +```clarity +(as-max-len? (list 1 2 3) u5) ;; Returns (some (1 2 3)) +(as-max-len? "Hello" u3) ;; Returns none + +;; Safe append +(define-public (add-to-list (item uint)) + (match (as-max-len? (append (var-get items) item) u100) + new-list (begin + (var-set items new-list) + (ok true)) + (err u1))) +``` + +## Control flow [#control-flow] + +### if [#if] + +`if` evaluates a condition and returns one of two values. + +**Signature** + +```clarity +(if condition true-branch false-branch) +``` + +**Parameters** + +| Name | Type | Description | +|------|------|-------------| +| `condition` | `bool` | Condition to evaluate | +| `true-branch` | any | Value if true | +| `false-branch` | any | Value if false | + +```clarity +(if (> u10 u5) + "Greater" + "Not greater") ;; Returns "Greater" + +;; Conditional logic +(define-public (withdraw (amount uint)) + (let ((balance (get-balance tx-sender))) + (if (>= balance amount) + (begin + (map-set balances tx-sender (- balance amount)) + (ok amount)) + (err u1)))) ``` -### unwrap! [#unwrap] +### match [#match] -`unwrap!` extracts the inner value from an optional or ok response. +`match` performs pattern matching on optional and response types. **Signature** ```clarity -(unwrap! optional-or-response thrown-value) +(match value + some-name some-branch + none-branch) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `optional-or-response` | optional/response | Value to unwrap | -| `thrown-value` | any | Value if none/err | +| `value` | optional/response | Value to match | +| `some-name` | symbol | Binding for some value | +| `some-branch` | expression | Expression if some | +| `none-branch` | expression | Expression if none | ```clarity -(unwrap! (some u42) (err u1)) ;; Returns u42 -(unwrap! none (err u404)) ;; Throws (err u404) +(match (map-get? balances tx-sender) + balance (ok balance) + (err u404)) -;; Safe access -(define-public (transfer-from-map (recipient principal)) - (let ((amount (unwrap! (map-get? pending-transfers tx-sender) (err u404)))) - (try! (ft-transfer? token amount tx-sender recipient)) - (map-delete pending-transfers tx-sender) - (ok amount))) +;; Response matching +(match (ft-transfer? token u100 tx-sender recipient) + success (ok "Transfer successful") + error (err error)) + +;; Nested matching +(define-read-only (get-user-name (user principal)) + (match (map-get? user-profiles user) + profile (match (get name profile) + name (ok name) + (err u1)) + (err u404))) ``` -### unwrap-err! [#unwrap-err] +### begin [#begin] -`unwrap-err!` extracts the error value from an err response. +`begin` executes multiple expressions in sequence. **Signature** ```clarity -(unwrap-err! response thrown-value) +(begin expr1 expr2... last-expr) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `response` | response | Response to unwrap | -| `thrown-value` | any | Value if ok | +| `expr1`, `expr2`, ... | any | Expressions to execute | +| `last-expr` | any | Final expression (return value) | ```clarity -(unwrap-err! (err u404) u0) ;; Returns u404 -(unwrap-err! (ok u42) u0) ;; Returns u0 +(begin + (print "Starting") + (var-set counter u1) + (ok true)) -;; Error handling -(define-public (handle-error) - (let ((error-code (unwrap-err! (process-action) u0))) - (print { error: error-code }) - (ok error-code))) +;; Multiple operations +(define-public (initialize) + (begin + (asserts! (is-eq tx-sender contract-owner) (err u401)) + (var-set is-initialized true) + (map-set admins tx-sender true) + (print { event: "initialized", by: tx-sender }) + (ok true))) ``` -### unwrap-panic [#unwrap-panic] +### let [#let] -`unwrap-panic` extracts a value or causes a runtime panic. +`let` creates local bindings for use in an expression. **Signature** ```clarity -(unwrap-panic optional-or-response) +(let ((name1 value1) (name2 value2)...) body) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `optional-or-response` | optional/response | Value to unwrap | +| `name` | symbol | Binding name | +| `value` | any | Value to bind | +| `body` | expression | Expression using bindings | ```clarity -(unwrap-panic (some u42)) ;; Returns u42 -(unwrap-panic none) ;; Runtime panic +(let ((x 10) (y 20)) + (+ x y)) ;; Returns 30 -;; Critical unwrap -(define-read-only (get-critical-value) - (unwrap-panic (map-get? critical-config "version"))) +;; Complex calculations +(define-public (calculate-reward (days uint)) + (let ( + (balance (get-balance tx-sender)) + (rate u5) ;; 5% annual + (reward (/ (* balance rate days) u36500))) + (begin + (map-set rewards tx-sender reward) + (ok reward)))) ``` -### unwrap-err-panic [#unwrap-err-panic] +## Optional & response types [#optional-response-types] -`unwrap-err-panic` extracts an error value or causes a runtime panic. +### some [#some] + +`some` constructs an optional value that contains a value. **Signature** ```clarity -(unwrap-err-panic response) +(some value) ``` **Parameters** | Name | Type | Description | |------|------|-------------| -| `response` | response | Response to unwrap | +| `value` | any | Value to wrap | ```clarity -(unwrap-err-panic (err u404)) ;; Returns u404 -(unwrap-err-panic (ok u42)) ;; Runtime panic +(some u42) ;; Returns (some u42) +(some "Hello") ;; Returns (some "Hello") -;; Force error -(define-read-only (get-error-code) - (unwrap-err-panic (always-fails))) +;; Return optional +(define-read-only (find-user (id uint)) + (if (map-get? users id) + (some (map-get? users id)) + none)) ``` ### is-ok [#is-ok] @@ -1846,61 +1993,6 @@ Clarity provides a comprehensive set of built-in functions for smart contract de (is-none (map-get? reserved-names name))) ``` -### try! [#try] - -`try!` attempts to unwrap a response, propagating any error. - -**Signature** - -```clarity -(try! response) -``` - -**Parameters** - -| Name | Type | Description | -|------|------|-------------| -| `response` | response | Response to try | - -```clarity -(try! (ok u42)) ;; Returns u42 -(try! (err u404)) ;; Propagates (err u404) - -;; Chain operations -(define-public (complex-operation (amount uint)) - (begin - (try! (check-preconditions amount)) - (try! (process-payment amount)) - (try! (update-records)) - (ok true))) -``` - -### default-to [#default-to] - -`default-to` returns a default value for none. - -**Signature** - -```clarity -(default-to default optional) -``` - -**Parameters** - -| Name | Type | Description | -|------|------|-------------| -| `default` | any | Default value | -| `optional` | optional | Optional value | - -```clarity -(default-to u0 (some u42)) ;; Returns u42 -(default-to u0 none) ;; Returns u0 - -;; Safe defaults -(define-read-only (get-balance-safe (user principal)) - (default-to u0 (map-get? balances user))) -``` - ## Fungible tokens [#fungible-tokens] ### define-fungible-token [#define-fungible-token] @@ -3237,87 +3329,3 @@ Key points: (ok true))) ``` -### as-max-len? [#as-max-len] - -`as-max-len?` checks if a sequence fits within a maximum length. - -**Signature** - -```clarity -(as-max-len? sequence max-length) -``` - -**Parameters** - -| Name | Type | Description | -|------|------|-------------| -| `sequence` | sequence | Sequence to check | -| `max-length` | uint | Maximum allowed length | - -```clarity -(as-max-len? (list 1 2 3) u5) ;; Returns (some (1 2 3)) -(as-max-len? "Hello" u3) ;; Returns none - -;; Safe append -(define-public (add-to-list (item uint)) - (match (as-max-len? (append (var-get items) item) u100) - new-list (begin - (var-set items new-list) - (ok true)) - (err u1))) -``` - -### merge [#merge] - -`merge` combines two tuples, with the second overriding the first. - -**Signature** - -```clarity -(merge tuple1 tuple2) -``` - -**Parameters** - -| Name | Type | Description | -|------|------|-------------| -| `tuple1` | tuple | Base tuple | -| `tuple2` | tuple | Override tuple | - -```clarity -(merge { a: u1, b: u2 } { b: u3, c: u4 }) -;; Returns { a: u1, b: u3, c: u4 } - -;; Update record -(define-public (update-profile (updates { name: (optional (string-ascii 50)), age: (optional uint) })) - (let ((current (default-to { name: "", age: u0 } (map-get? profiles tx-sender)))) - (map-set profiles tx-sender (merge current updates)) - (ok true))) -``` - -### get [#get] - -`get` extracts a value from a tuple by key. - -**Signature** - -```clarity -(get key tuple) -``` - -**Parameters** - -| Name | Type | Description | -|------|------|-------------| -| `key` | symbol | Key to extract | -| `tuple` | tuple | Tuple to access | - -```clarity -(get balance { balance: u100, locked: u50 }) ;; Returns u100 - -;; Access nested data -(define-read-only (get-user-balance (user principal)) - (match (map-get? accounts user) - account (get balance account) - u0)) -``` \ No newline at end of file diff --git a/content/docs/tools/bitcoin-indexer/index.mdx b/content/docs/tools/bitcoin-indexer/index.mdx index 1b5d5323c..ae15f6f4e 100644 --- a/content/docs/tools/bitcoin-indexer/index.mdx +++ b/content/docs/tools/bitcoin-indexer/index.mdx @@ -1,17 +1,13 @@ --- title: Bitcoin Indexer sidebarTitle: Overview -description: Run your own Bitcoin metaprotocol indexer with built-in support for Ordinals, Runes, and BRC-20 tokens. +description: The Bitcoin Indexer is a high-performance, reorg-aware indexing engine that tracks Bitcoin metaprotocols and serves API endpoints for Ordinals, Runes, and BRC-20 tokens. llm: false --- ## Overview -The Bitcoin Indexer is a high-performance, reorg-aware indexing engine that tracks Bitcoin metaprotocols and serves API endpoints for Ordinals, Runes, and BRC-20 tokens. Unlike basic indexers, it automatically handles blockchain reorganizations, ensuring your data stays accurate without manual intervention. - -![Bitcoin Indexer overview](/images/tools/bitcoin-indexer/overview.svg) - -The indexer connects to your Bitcoin node, processes blocks in real-time, stores metaprotocol data in PostgreSQL, and serves REST APIs for each protocol. +The Bitcoin Indexer connects to your Bitcoin node, processes blocks in real-time, stores metaprotocol data in PostgreSQL, and serves REST APIs for each protocol. ## Key features diff --git a/content/docs/tools/chainhook/index.mdx b/content/docs/tools/chainhook/index.mdx index 54e246eaa..f1de1ba83 100644 --- a/content/docs/tools/chainhook/index.mdx +++ b/content/docs/tools/chainhook/index.mdx @@ -11,24 +11,7 @@ Chainhook is a reorg-aware indexer that lets you build custom event streams from To explore Chainhook features with AI, copy and paste [llms.txt](/tools/chainhook/llms.txt) into your LLM of choice. - +![Chainhook overview](/images/tools/chainhook/overview.svg) ## Key features @@ -69,4 +52,4 @@ $ cd chainhook && cargo chainhook-install type: help ### Need help building with Chainhook? Reach out to us on the **#chainhook** channel on [Discord](https://stacks.chat/) under the Hiro Developer Tools section. There's also a [weekly office hours](https://www.addevent.com/event/oL21905919) call every Thursday at 11am ET. -::: \ No newline at end of file +::: diff --git a/content/docs/tools/contract-monitoring/index.mdx b/content/docs/tools/contract-monitoring/index.mdx index 5ca623638..9c3dd747e 100644 --- a/content/docs/tools/contract-monitoring/index.mdx +++ b/content/docs/tools/contract-monitoring/index.mdx @@ -1,35 +1,14 @@ --- title: Contract monitoring sidebarTitle: Overview -description: Contract monitoring is fully managed—no infrastructure setup, no node maintenance, just instant notifications delivered to your endpoints. +description: Contract monitoring lets you track smart contract events in real-time and receive webhook notifications when specific activities occur. llm: false --- ## Overview -Contract monitoring in the Hiro Platform lets you track smart contract events in real-time and receive webhook notifications when specific activities occur. - To explore Contract monitoring features with AI, copy and paste [llms.txt](/tools/contract-monitoring/llms.txt) into your LLM of choice. - - ## Key features - **Real-time notifications** - Target specific events and receive webhooks within seconds @@ -44,4 +23,4 @@ graph LR type: help ### Need help with contract monitoring? Reach out to us on the #api channel on [Discord](https://stacks.chat/) under the Hiro Developer Tools section. -::: \ No newline at end of file +::: diff --git a/public/images/tools/chainhook/overview.svg b/public/images/tools/chainhook/overview.svg new file mode 100644 index 000000000..078b3b1b3 --- /dev/null +++ b/public/images/tools/chainhook/overview.svg @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +