ERCs
ERC-165 — Standard Interface Detection
A contract declares which interfaces it supports via supportsInterface(bytes4) — returning true for interface IDs it implements. The interface ID is the XOR of the function selectors.
import { eip155_1 } from "@ethernauta/chain/eip155-1";
import { AddressSchema, Bytes4Schema } from "@ethernauta/core";
import { supportsInterface } from "@ethernauta/erc/165";
import { eth_call } from "@ethernauta/eth";
import { contract, create_reader, encode_chain_id, http } from "@ethernauta/transport";
import { parse } from "valibot";
const CHAIN_ID = encode_chain_id({ namespace: "eip155", reference: eip155_1.chainId });
const reader = create_reader([
{ chainId: CHAIN_ID, transports: [http("https://ethereum-rpc.publicnode.com")] },
]);
const nft_address = parse(AddressSchema, "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D");
const callable = supportsInterface({ interfaceId: parse(Bytes4Schema, "0x80ac58cd") })(
contract({ chain_id: CHAIN_ID, to: nft_address }),
);
const result_bytes = await eth_call([{ to: callable.to, input: callable.data }])(reader({ chain_id: CHAIN_ID }));
const ok = callable.decode(result_bytes);
// true → contract implements ERC-721 Surface
| Method | Shape | Purpose |
|---|---|---|
supportsInterface({ interface_id }) | Callable<boolean> | Per-interface detection. |
Common interface IDs
| ID | Standard |
|---|---|
0x80ac58cd | ERC-721 |
0x5b5e139f | ERC-721 Metadata |
0x780e9d63 | ERC-721 Enumerable |
0xd9b67a26 | ERC-1155 |
0x0e89341c | ERC-1155 Metadata URI |
0x2a55205a | ERC-2981 (royalties) |
See also
- ERC-721, ERC-1155 — typical 165-aware contracts.
- @ethernauta/erc/registry — selector → method lookup.