Messages
No examples found{
"action": "<string>",
"chain_id": 123,
"dataset_id": "<string>"
}No examples foundNo examples found{
"chain_id": 123,
"dataset_id": "<string>",
"is_reorg": true,
"data": {
"address": "<string>",
"block_number": 123,
"tx_index": 123,
"_tracing_id": "<string>"
}
}Primitives
Contracts
Subscribe to real-time contract deployment notifications and metadata.
WSS
/
Overview
- Dataset ID:
0121 - Contracts - Description: Smart contracts discovered via CREATE/CREATE2 internal transactions. Uses
contract_id(26 bytes = address + creation_block + tx_index) as primary key to support metamorphic contracts (e.g. CREATE-SELFDESTRUCT-CREATE2 in the same block). - Sample: Hugging Face Sample
Subscription Parameters
Filter notifications to specific deployed contract addresses (hex string, 20 bytes, no
0x prefix).Message Fields
Payload fields mirrorblockdb_evm.b0121_contracts_v1 (binary fields as hex strings without 0x in JSON).
Contract incarnation ID (hex, 26 bytes): 20 bytes address + 4 bytes creation block + 2 bytes tx index.
Deployed contract address (hex string, 20 bytes, no
0x prefix).Block height containing the contract creation.
Block time (ISO-8601).
Zero-based index of the deployment transaction within the block.
Position in the call tree (e.g.,
"0", "0.0", "0.1.2").Address that deployed the contract (msg.sender of CREATE/CREATE2). Hex string, 20 bytes, no
0x prefix.Creation call type (
CREATE or CREATE2).Lineage id (hex).
Record creation time (ISO-8601).
Record last update time (ISO-8601).
Subscription Example
# Use wscat to connect and subscribe
wscat -c wss://api.blockdb.io/v1/evm/ \
-H "Authorization: Bearer $BLOCKDB_API_KEY" \
-x '{"action": "subscribe", "dataset_id": "0121", "chain_id": 1, "params": {}}'
#include <libwebsockets.h>
#include <string.h>
#include <stdio.h>
static int callback_blockdb(struct lws *wsi, enum lws_callback_reasons reason,
void *user, void *in, size_t len) {
switch (reason) {
case LWS_CALLBACK_CLIENT_ESTABLISHED:
lws_callback_on_writable(wsi);
break;
case LWS_CALLBACK_CLIENT_RECEIVE:
printf("Received: %s\n", (char *)in);
break;
case LWS_CALLBACK_CLIENT_WRITEABLE: {
unsigned char buf[LWS_PRE + 512];
unsigned char *p = &buf[LWS_PRE];
size_t n = sprintf((char *)p, "{\"action\": \"subscribe\", \"dataset_id\": \"0121\", \"chain_id\": 1, \"params\": {}}");
lws_write(wsi, p, n, LWS_WRITE_TEXT);
break;
}
}
return 0;
}
using System;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
class Program {
static async Task Main() {
using var ws = new ClientWebSocket();
ws.Options.SetRequestHeader("Authorization", $"Bearer {Environment.GetEnvironmentVariable("BLOCKDB_API_KEY")}");
await ws.ConnectAsync(new Uri("wss://api.blockdb.io/v1/evm/"), CancellationToken.None);
var subMsg = "{\"action\": \"subscribe\", \"dataset_id\": \"0121\", \"chain_id\": 1, \"params\": {}}";
await ws.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes(subMsg)), WebSocketMessageType.Text, true, CancellationToken.None);
var buffer = new byte[1024 * 4];
while (ws.State == WebSocketState.Open) {
var result = await ws.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
Console.WriteLine(Encoding.UTF8.GetString(buffer, 0, result.Count));
}
}
}
import websocket
import json
import os
def on_message(ws, message):
print(f"Received: {message}")
def on_open(ws):
msg = {
"action": "subscribe",
"dataset_id": "0121",
"chain_id": 1,
"params": {}
}
ws.send(json.dumps(msg))
ws = websocket.WebSocketApp(
"wss://api.blockdb.io/v1/evm/",
header={"Authorization": f"Bearer {os.getenv('BLOCKDB_API_KEY')}"},
on_message=on_message,
on_open=on_open
)
ws.run_forever()
const WebSocket = require('ws');
const ws = new WebSocket('wss://api.blockdb.io/v1/evm/', {
headers: { 'Authorization': `Bearer ${process.env.BLOCKDB_API_KEY}` }
});
ws.on('open', () => {
ws.send(JSON.stringify({
action: 'subscribe',
dataset_id: '0121',
chain_id: 1,
params: {}
}));
});
ws.on('message', (data) => {
console.log('Received:', JSON.parse(data));
});
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/gorilla/websocket"
)
func main() {
header := http.Header{"Authorization": []string{"Bearer " + os.Getenv("BLOCKDB_API_KEY")}}
c, _, err := websocket.DefaultDialer.Dial("wss://api.blockdb.io/v1/evm/", header)
if err != nil {
log.Fatal("dial:", err)
}
defer c.Close()
sub := `{"action": "subscribe", "dataset_id": "0121", "chain_id": 1, "params": {}}`
err = c.WriteMessage(websocket.TextMessage, []byte(sub))
if err != nil {
log.Fatal("write:", err)
}
for {
_, message, err := c.ReadMessage()
if err != nil {
log.Fatal("read:", err)
}
fmt.Printf("Received: %s\n", message)
}
}
Response Example
{
"chain_id": 1,
"dataset_id": "0121",
"is_reorg": false,
"data": {
"contract_id": "1234567890abcdef1234567890abcdef1234567800121a0700",
"contract_address": "1234567890abcdef1234567890abcdef12345678",
"block_number": 18934221,
"block_time": "2024-04-01T12:34:56Z",
"tx_index": 7,
"trace_address": "0",
"creator_address": "0000000000000000000000000000000000000000",
"creation_call_type": "CREATE2",
"_tracing_id": "0121000000000000000000000000000000000001",
"_created_at": "2025-11-11T18:42:15.123Z",
"_updated_at": "2025-11-11T18:42:15.123Z"
}
}
Messages
No examples found{
"action": "<string>",
"chain_id": 123,
"dataset_id": "<string>"
}No examples foundNo examples found{
"chain_id": 123,
"dataset_id": "<string>",
"is_reorg": true,
"data": {
"address": "<string>",
"block_number": 123,
"tx_index": 123,
"_tracing_id": "<string>"
}
}subscribe
type:object
unsubscribe
type:object
subscribe_response
type:object
unsubscribe_response
type:object
update
type:object
Last modified on April 6, 2026
Was this page helpful?
⌘I