Querying
All five query functions demonstrated against live Sepolia data.
These examples run against Sepolia testnet (
network="sepolia"). To run against Base mainnet: replaceconfigure(network="sepolia")withconfigure(network="base"). All function calls, record structures, and output shapes are identical across networks.
[1]:
# Cell 1 — setup
from anchorregistry import configure, get_by_arid, get_by_registrant, get_by_tree, get_by_type, get_all, BASE_SEPOLIA_RPC, V1A_BASE_SEPOLIA
from anchorregistry import ARTIFACT_TYPE_MAP, BASE_SEPOLIA_RPC, V1A_BASE_SEPOLIA
from anchorregistry.enums import ArtifactType
configure(
network="base-sepolia",
contract_address=V1A_BASE_SEPOLIA,
rpc_url=BASE_SEPOLIA_RPC, # swap for Infura / Alchemy URL for faster scans
)
[2]:
# Cell 2 — get_by_arid
# Fetch a single anchor by its AR-ID
record = get_by_arid("AR-2026-dPXazj6")
print(f"Type: {record['artifact_type_name']}")
print(f"Title: {record['title']}")
print(f"Data: {record['data']}")
Type: RESEARCH
Title: test sepolia anchor
Data: {'doi': '', 'institution': '', 'co_authors': '', 'url': 'https://anchorregistry.com/'}
[3]:
# Cell 3 — get_by_registrant
# Fetch all anchors registered by a specific wallet address
records = get_by_registrant("0xc7a7afde1177fbf0bb265ea5a616d1b8d7ed8c44")
print(f"Total anchors by registrant: {len(records)}")
Total anchors by registrant: 5
[4]:
# Cell 4 — get_by_tree
# Fetch all anchors belonging to a named artifact tree
records = get_by_tree("0xf07140ce4deaf3b5dac859091a079f82e9656f173593feda7895d940b8fa5d13")
print(f"Total anchors in tree: {len(records)}")
Total anchors in tree: 1
[5]:
# Cell 5 — get_by_type
# Fetch all anchors of a given artifact type
research_anchors = get_by_type(ArtifactType.RESEARCH)
print(f"RESEARCH anchors on Sepolia: {len(research_anchors)}")
RESEARCH anchors on Sepolia: 1
[6]:
# Cell 6 — get_all
# Reconstruct the full registry — all anchors from deploy block to latest
all_records = get_all()
print(f"Total anchors on Sepolia: {len(all_records)}")
Total anchors on Sepolia: 5
[7]:
# Cell 7 — ARTIFACT_TYPE_MAP
# Maps integer type indices to human-readable names
# Useful for decoding artifact_type_index in raw records
{k: v for k, v in ARTIFACT_TYPE_MAP.items()}
[7]:
{0: 'CODE',
1: 'RESEARCH',
2: 'DATA',
3: 'MODEL',
4: 'AGENT',
5: 'MEDIA',
6: 'TEXT',
7: 'POST',
8: 'ONCHAIN',
9: 'REPORT',
10: 'NOTE',
11: 'WEBSITE',
12: 'EVENT',
13: 'RECEIPT',
14: 'LEGAL',
15: 'ENTITY',
16: 'PROOF',
17: 'SEAL',
18: 'RETRACTION',
19: 'REVIEW',
20: 'VOID',
21: 'AFFIRMED',
22: 'ACCOUNT',
23: 'OTHER'}