{ "cells": [ { "cell_type": "markdown", "id": "b2c3d4e5-0002-0000-0000-000000000001", "metadata": {}, "source": [ "# Quickstart\n", "\n", "Minimal working example. One anchor, live output.\n", "\n", "> These examples run against Sepolia testnet (`network=\"sepolia\"`).\n", "> To run against Base mainnet: replace `configure(network=\"sepolia\")` with `configure(network=\"base\")`.\n", "> All function calls, record structures, and output shapes are identical across networks." ] }, { "cell_type": "code", "execution_count": 1, "id": "b2c3d4e5-0002-0000-0000-000000000002", "metadata": {}, "outputs": [], "source": [ "# Cell 1 — setup\n", "from anchorregistry import configure, get_by_arid, BASE_SEPOLIA_RPC, V1A_BASE_SEPOLIA\n", "\n", "configure(\n", " network=\"base-sepolia\",\n", " contract_address=V1A_BASE_SEPOLIA,\n", " rpc_url=BASE_SEPOLIA_RPC, # swap for Infura / Alchemy URL for faster scans\n", ")\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "b2c3d4e5-0002-0000-0000-000000000003", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'ar_id': 'AR-2026-dPXazj6',\n", " 'registered': True,\n", " 'artifact_type_index': 1,\n", " 'artifact_type_name': 'RESEARCH',\n", " 'tx': '0x826f623ce984a9cadeb5d72c710d279e7385cd83ee4815d092e393d5d574ec57',\n", " 'block': 40225238,\n", " 'registrant': '0xc7a7afde1177fbf0bb265ea5a616d1b8d7ed8c44',\n", " 'manifest_hash': '981e16e83f1e0068d87a89e04962b9287bb5f024782beca6fec837304e8c308e',\n", " 'parent_ar_id': '',\n", " 'descriptor': '',\n", " 'title': 'test sepolia anchor',\n", " 'author': '',\n", " 'tree_id': '0xf07140ce4deaf3b5dac859091a079f82e9656f173593feda7895d940b8fa5d13',\n", " 'token_commitment': '0xf07140ce4deaf3b5dac859091a079f82e9656f173593feda7895d940b8fa5d13',\n", " 'data': {'doi': '',\n", " 'institution': '',\n", " 'co_authors': '',\n", " 'url': 'https://anchorregistry.com/'}}" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Cell 2 — fetch a single anchor\n", "record = get_by_arid(\"AR-2026-dPXazj6\")\n", "record" ] }, { "cell_type": "markdown", "id": "b2c3d4e5-0002-0000-0000-000000000004", "metadata": {}, "source": [ "Every record has two levels:\n", "\n", "- **Universal fields** — `ar_id`, `title`, `author`, `artifact_type_name`, `manifest_hash`, `registrant`, `tree_id`, `parent_ar_id`, `token_commitment`, `block`, `tx`\n", "- **Type-specific fields** — nested under `record[\"data\"]`, keys depend on `artifact_type_name`\n", "\n", "For `RESEARCH` records, `data` contains: `doi`, `institution`, `co_authors`, `url`." ] }, { "cell_type": "code", "execution_count": 3, "id": "eox9p4d7etr", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "AnchorNotFoundError: AR-ID not found on-chain: AR-0000-INVALID\n" ] } ], "source": [ "# Cell 3 — error handling\n", "from anchorregistry import AnchorNotFoundError, ConfigurationError\n", "\n", "try:\n", " get_by_arid(\"AR-0000-INVALID\")\n", "except AnchorNotFoundError as e:\n", " print(f\"AnchorNotFoundError: {e}\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.15" } }, "nbformat": 4, "nbformat_minor": 5 }