{"uid":"cap_zfVADJHgjLdzrhjbFiF_X","slug":"function-selector-encoder-13ea5245","name":"Function Selector Encoder","description":"Computes the 4-byte selector for a function signature (e.g. transfer(address,uint256) → 0xa9059cbb). The inverse of the decoder — useful for agents building or matching calldata.","url":"https://402.com.tr/api/x402/encode-selector","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"},"pathParams":{"type":"object"},"queryParams":{"type":"object","required":["signature"],"properties":{"signature":{"type":"string","description":"Function signature"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object"}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.01","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.01/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_uRx7p-ncizyP9UBQYAo9m","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.01","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes the 4-byte ABI function selector from a Solidity function signature string (e.g. transfer(address,uint256) → 0xa9059cbb)","exampleAgentPrompt":"What's the 4-byte function selector for transfer(address,uint256)? I need the hex value to match against some calldata I'm inspecting.","exampleUseCases":[{"title":"Verify calldata method routing","prompt":"I have raw calldata starting with 0xa9059cbb — can you confirm that encodes to the transfer(address,uint256) selector so I know which function is being called?"},{"title":"Build calldata for contract interaction","prompt":"I'm constructing an ERC-20 approve call manually — what's the 4-byte selector for approve(address,uint256) so I can prepend it to my encoded parameters?"},{"title":"Match selector in transaction decoder","prompt":"My transaction decoder found function ID 0x095ea7b3 — can you encode approve(address,uint256) to a selector and confirm they match?"}],"resultDescription":"Returns the 4-byte hexadecimal function selector (e.g. 0xa9059cbb) derived by taking the first 4 bytes of the keccak256 hash of the canonical function signature string. This is the same discriminator prefix prepended to EVM calldata to identify which function is being invoked.","failureModes":["Missing 'signature' query parameter returns an error","Malformed or non-canonical function signature (e.g. spaces, wrong type names) may produce an unexpected selector or validation error","Network timeout or service unavailability returns a non-200 response","Invalid method type other than GET is rejected"],"whenToPreferThis":"Use this endpoint when you need to programmatically compute the EVM calldata selector for a known function signature, especially when building or validating raw calldata, matching an unknown 4-byte prefix to a known function, or checking selector collisions. Prefer this over doing the keccak256 hash manually when working in an agent context that doesn't have direct cryptographic primitives available.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T12:52:45.178Z","isFirstParty":false}