VIZ.cx
← Learn

Read your first block

5 minbeginner

Every VIZ transaction is packed into a block. This guide shows you how to fetch a block by number and inspect the operations inside it — using both a raw RPC call and the @viz-cx/core TypeScript SDK.

Step 1 — Fetch a block with curl

VIZ nodes speak JSON-RPC 2.0 over HTTP POST. Send a get_block request to the public node:

curl -X POST https://node.viz.cx \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"get_block","params":{"block_num":1}}'

The node returns a block object:

{
  "previous": "0000000000000000000000000000000000000000",
  "timestamp": "2019-10-01T07:00:00",
  "witness": "committee",
  "transaction_merkle_root": "0000000000000000000000000000000000000000",
  "transactions": []
}

Step 2 — Same call via @viz-cx/core

The SDK wraps the RPC call and handles serialization. getBlock returns null for blocks that do not exist yet.

import { createClient } from '@viz-cx/core'

const client = createClient({ endpoint: 'https://node.viz.cx' })

const block = await client.api.getBlock(1)
if (!block) { console.log('block not found'); process.exit(1) }

console.log('timestamp:', block.timestamp)
console.log('witness:  ', block.witness)
console.log('tx count: ', block.transaction_ids.length)

Step 3 — Inspect the operations in a block

get_ops_in_block returns the full operation list with metadata (transaction ID, op type, timestamp). The only_virtual flag filters to virtual ops (consensus rewards) when true.

curl -X POST https://node.viz.cx \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"get_ops_in_block","params":{"block_num":1,"only_virtual":false}}'

Each operation is a [type, data] tuple. Common types: transfer, award, account_create, delegate_vesting_shares.