---
title: "Solidity function selector: Keccak-256, 4-byte selector and event topic from a signature"
method: GET
path: "/v1/chain/selector"
tags: ["deterministic", "no-api-key", "chain", "blockchain", "solidity", "keccak"]
---

# Solidity function selector: Keccak-256, 4-byte selector and event topic from a signature

`GET /v1/chain/selector`

## Request

- Base URL: `https://api.duoleads.com`
- URL: `https://api.duoleads.com/v1/chain/selector`
- Auth: none declared

Solidity function selector and event topic: compute the Keccak-256 hash of a function or event signature and derive the 4-byte selector and the 32-byte topic. Normalises the signature first — strips parameter names, expands uint to uint256 and the other aliases, flattens tuples — so a signature copied from source code produces the same selector as the canonical form. Also hashes arbitrary text or hex bytes with Keccak-256.

**Output (`data`):** canonical (string|null, null in data mode), keccak256 (0x + 32 bytes), selector (0x + 4 bytes; string|null, null for kind=event and in data mode), topic0 (0x + 32 bytes; string|null, null for kind=function or error and in data mode), inputs ([] or null, null in data mode), normalisations [{from, to}]. Data mode (data= instead of signature, hashing arbitrary text or hex bytes with Keccak-256): canonical, selector, topic0 and inputs are null, normalisations is empty, and encoding (utf8|hex) and input_bytes (integer) are added.

Deterministic: identical input returns identical output, so the response is served with `Cache-Control: private, max-age=31536000, immutable` (the paying client may cache it indefinitely; shared caches must not, because the response is paid).

Price: $0.05 USDC per call (x402, Base). Route contract version 1.0.0. Docs: https://api.duoleads.com/docs#chain-selector

## Query parameters

- `signature` string
- `data` string
- `encoding` 'utf8' | 'hex'
- `kind` 'function' | 'event' | 'error'

## Response `200`

Paid and settled. `data` is route-specific; a route that judges its input returns 200 with `data.valid: false` for a bad value.

- object
  - `ok` unknown, required
  - `route` '/v1/chain/selector', required
  - `version` '1.0.0', required
  - `data` object, required: canonical (string|null, null in data mode), keccak256 (0x + 32 bytes), selector (0x + 4 bytes; string|null, null for kind=event and in data mode), topic0 (0x + 32 bytes; string|null, null for kind=function or error and in data mode), inputs ([] or null, null in data mode), normalisations [{from, to}]. Data mode (data= instead of signature, hashing arbitrary text or hex bytes with Keccak-256): canonical, selector, topic0 and inputs are null, normalisations is empty, and encoding (utf8|hex) and input_bytes (integer) are added.
    - `canonical` string, nullable, required
    - `keccak256` string, required
    - `selector` string, nullable, required
    - `topic0` string, nullable, required
    - `inputs` string[], nullable, required
    - `normalisations` object[], required
      - `from` string, required
      - `to` string, required
    - `encoding` string
    - `input_bytes` integer
  - `meta` Meta, required
    - `disclaimer` string, required: Legal short disclaimer, identical on every response.
    - `request_id` string, required: ULID.
    - `computed_at` string, date-time, required: RFC 3339 UTC with milliseconds.
    - `price_usd` string, required: Decimal string, "0.05".
    - `deterministic` boolean, required
    - `sources` object[]: Present only on routes that read a vendored dataset: the exact edition that answered.
      - `id` string, required
      - `version` string, required
      - `published` string, required
      - `attribution` string
      - `licence` string

## Other responses

- `400`: MISSING_PARAM, INVALID_PARAM or UNSUPPORTED_VALUE. Not charged: validation runs before the paywall.
- `402`: Payment required. No valid PAYMENT-SIGNATURE was supplied: read the base64 PAYMENT-REQUIRED header (or this body) for the price ($0.05 = 50000 atomic USDC on eip155:8453), sign an EIP-3009 authorization and retry. Also returned when settlement is declined (PAYMENT_FAILED). Nothing is charged on a 402.
- `404`: NOT_FOUND: unknown path. Not charged.
- `405`: METHOD_NOT_ALLOWED: only GET and HEAD are served. Not charged.
- `413`: INPUT_TOO_LARGE: a parameter exceeded its documented maximum length. Not charged.
- `500`: INTERNAL: a server bug. Not charged.

---

[API](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo.md) · [All operations](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo/llms.txt) · [OpenAPI document](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo/revisions/18790d59615e?raw)
