{"uid":"cap_it-SO-XsTsvwkZX3E_wxi","slug":"duo-data-utilities-solidity-keccak-256-selector-topic-derivation-a1dba4ff","name":"Duo Data Utilities – Solidity Keccak-256 Selector & Topic Derivation","description":"Compute the Keccak-256 hash of a Solidity function or event signature and derive the 4-byte function selector and the 32-byte event 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.","url":"https://api.duoleads.com/v1/chain/selector?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":[],"properties":{"data":{"type":"string","maxLength":8192,"description":"Alternative to signature: raw data to Keccak-256 hash."},"kind":{"enum":["function","event","error"],"type":"string","default":"function","maxLength":64,"description":"function (default), event or error."},"encoding":{"enum":["utf8","hex"],"type":"string","default":"utf8","maxLength":64,"description":"Encoding of data: utf8 (default) or hex."},"signature":{"type":"string","maxLength":1024,"description":"Solidity function, event or error signature, e.g. transfer(address to, uint amount)."}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","required":["ok","route","version","data","meta"],"properties":{"ok":{"const":true},"data":{"type":"object","required":["canonical","keccak256","selector","topic0","inputs","normalisations"],"properties":{"inputs":{"type":["array","null"],"items":{"type":"string"}},"topic0":{"type":["string","null"]},"encoding":{"type":"string"},"selector":{"type":["string","null"]},"canonical":{"type":["string","null"]},"keccak256":{"type":"string"},"input_bytes":{"type":"integer"},"normalisations":{"type":"array","items":{"type":"object","required":["from","to"],"properties":{"to":{"type":"string"},"from":{"type":"string"}}}}}},"meta":{"type":"object","required":["request_id","computed_at","price_usd","deterministic","disclaimer"],"properties":{"sources":{"type":"array","items":{"type":"object","required":["id","version","published"]}},"price_usd":{"type":"string"},"disclaimer":{"type":"string"},"request_id":{"type":"string"},"computed_at":{"type":"string","description":"RFC 3339 UTC with milliseconds"},"deterministic":{"type":"boolean"}}},"route":{"const":"/v1/chain/selector"},"version":{"type":"string"}}}}}}},"responseSchema":{"type":"json","example":{"ok":true,"data":{"inputs":["address","uint256"],"topic0":null,"selector":"0xa9059cbb","canonical":"transfer(address,uint256)","keccak256":"0xa9059cbb2ab09eb219583f4a59a5d0623ade346d962bcd4e46b11da047c9049b","normalisations":[]},"meta":{"price_usd":"0.05","disclaimer":"Factual output of a deterministic computation over public data. Provided as is, with no warranty of accuracy, completeness or availability. Not investment, financial, legal, tax, medical or any other professional advice, and not a recommendation. Verify before relying on it. Terms: https://api.duoleads.com/terms","request_id":"01K6B7Q4ZC8H3F2M9WXR5TYN0D","computed_at":"2026-09-28T12:00:00.000Z","deterministic":true},"route":"/v1/chain/selector","version":"1.0.0"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.05","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.05/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_bWafdxAwjdFHuGp88-4PO","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.05","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes the Keccak-256 hash of a Solidity function, event, or error signature to derive the 4-byte function selector and 32-byte event topic, with automatic signature normalisation; also hashes arbitrary text or hex bytes.","exampleAgentPrompt":"What is the 4-byte function selector and full Keccak-256 hash for the Solidity function signature 'transfer(address to, uint amount)' — treat it as a function kind?","exampleUseCases":[{"title":"ERC-20 transfer selector lookup","prompt":"Can you give me the 4-byte ABI selector for the ERC-20 transfer function 'transfer(address to, uint amount)' — I need the canonical form and the hex selector so I can encode a calldata payload."},{"title":"Smart contract event topic derivation","prompt":"I need the topic0 for the Solidity event 'Transfer(address indexed from, address indexed to, uint256 value)' so I can filter Ethereum logs — can you compute it as an event kind?"},{"title":"Arbitrary text Keccak-256 hashing","prompt":"Please Keccak-256 hash the UTF-8 string 'Hello, World!' for me — I just need the raw hash output."}],"resultDescription":"Returns a JSON object with the canonical Solidity signature, list of parsed input types, 4-byte selector (for functions/errors) or null, 32-byte topic0 (for events) or null, full 32-byte Keccak-256 hash, and a list of any normalisations applied (e.g. uint→uint256 expansions). Metadata includes request ID, computed timestamp, price, and a determinism flag.","failureModes":["Missing both 'signature' and 'data' query parameters returns a validation error","Malformed or unparseable Solidity signature returns a parse error","Invalid hex encoding when encoding=hex causes a bad-request error","Unsupported 'kind' enum value returns a validation error","Signature exceeding 1024 characters is rejected","Network or upstream timeout returns a 5xx error"],"whenToPreferThis":"Choose this endpoint when you need to compute Solidity ABI selectors, event topics, or Keccak-256 hashes of signatures in a single deterministic call with automatic normalisation (uint→uint256, tuple flattening, parameter name stripping). It is particularly valuable when working with raw or human-readable Solidity signatures copied from source code that may not yet be in canonical form. Prefer this over rolling your own keccak library when you need the canonical signature and normalisation audit trail alongside the hash.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-02T00:30:59.446Z","isFirstParty":false,"canonicalSlug":"duo-data-utilities-solidity-keccak-256-selector-topic-derivation-a1dba4ff"}