Decastecastdocstestnet

Reference

Events & Hiro API

Every Decast action prints at three levels. Read any of them with one Hiro API call.

Endpoint

GEThttps://api.testnet.hiro.so/extended/v2/smart-contracts/{contract_id}/logs?limit=50
  • limit — page size (we use 50).
  • cursor — pass prev_cursor from a response to page back through older events, or next_cursor for newer ones.
  • Results are newest first.

Response

json
{
  "limit": 50,
  "offset": 0,
  "total": 22,
  "next_cursor": null,
  "prev_cursor": "1055800:2147483647:1:7",
  "cursor": "1069336:2147483647:0:4",
  "results": [
    {
      "event_index": 4,
      "event_type": "smart_contract_log",
      "tx_id": "0xfdf76ed4…5d74b9b",
      "contract_log": {
        "contract_id": "STHF68B9S6RMS36EX5YZJ3W4PCA24FAQJ4HQGZYK.decast-interface-v1",
        "topic": "print",
        "value": { "hex": "0x0c00000008…" }
      }
    }
  ]
}

The interesting part is contract_log.value.hex: the printed Clarity value, serialized.

Decoding

Decode the hex into a tuple. For app and global events, the payload field is itself a serialized tuple, so decode it a second time.

javascript
import { hexToCV, cvToJSON, deserializeCV } from "@stacks/transactions";

const url = "https://api.testnet.hiro.so/extended/v2/smart-contracts/STHF68B9S6RMS36EX5YZJ3W4PCA24FAQJ4HQGZYK.decast-interface-v1/logs?limit=50";
const { results, prev_cursor } = await fetch(url).then((r) => r.json());

for (const log of results) {
  // 1. Outer print value -> tuple
  const event = cvToJSON(hexToCV(log.contract_log.value.hex)).value;

  // 2. App and global events wrap the post/boost in a serialized buffer
  if (event.payload) {
    const payload = cvToJSON(deserializeCV(event.payload.value.replace(/^0x/, "")));
    console.log(event.event.value, payload.value);
  } else {
    console.log(event); // user contract: tuple is the payload itself
  }
}

// Older pages: append &cursor=${prev_cursor}

Events by scope

user

User contract

One person's timeline: the raw post and boost payload tuples their contract prints. Swap in any user's contract id.

GEThttps://api.testnet.hiro.so/extended/v2/smart-contracts/ST2K5SEC5KQ863QM3H0AN3FK69XSJV3YV16507WX8.decast-user-v1/logs?limit=50
event shape
{
  last-token-id, message, via-url, amount-to-stack,
  content-uri, content-hash, thumbnail-uri, thumbnail-hash,
  metadata-uri, interface-contract, referral-principal,
  interface-fee-ustx, interface-referral-percent, interface-treasury-principal,
  protocol-fee-ustx, protocol-treasury-principal,
  referal-amount, interface-treasury-amount,
  charity-address, charity-amount
}
app

App contract

Every post and boost made through one app. Swap in your own interface contract id.

GEThttps://api.testnet.hiro.so/extended/v2/smart-contracts/STHF68B9S6RMS36EX5YZJ3W4PCA24FAQJ4HQGZYK.decast-interface-v1/logs?limit=50
event shape
{
  event: "decast-postx" | "decast-boostx",
  scope: "interface",
  author,
  user-contract-address, user-contract-hash,
  interface-contract-address, interface-contract-hash,
  payload  ;; (buff) serialized post/boost tuple
}
global

Global posts · decast-feed

Protocol-wide post stream. Each log wraps the post payload printed by decast-feed.

GEThttps://api.testnet.hiro.so/extended/v2/smart-contracts/ST27J8CK2MP0TE57CT9DP0X672EWXDRR3FEGZJKPJ.decast-feed/logs?limit=50
event shape
;; decoded from the print value
{ event: "decast-postx", ..., payload }
global

Global boosts · decast-boosts

Protocol-wide boost stream.

GEThttps://api.testnet.hiro.so/extended/v2/smart-contracts/ST27J8CK2MP0TE57CT9DP0X672EWXDRR3FEGZJKPJ.decast-boosts/logs?limit=50
event shape
;; decoded from the print value
{ event: "decast-boostx", ..., payload }