ERCs
ERC-2981 — NFT Royalty Standard
A standard way for NFTs to declare a royalty: given a sale price, the contract returns the royalty recipient and the amount.
import { eip155_1 } from "@ethernauta/chain/eip155-1";
import { AddressSchema, Uint256Schema } from "@ethernauta/core";
import { royaltyInfo } from "@ethernauta/erc/2981";
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 collection = parse(AddressSchema, "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D");
const callable = royaltyInfo({
tokenId: parse(Uint256Schema, "0x1"),
salePrice: parse(Uint256Schema, "0xDE0B6B3A7640000"), // 1 ether
})(contract({ chain_id: CHAIN_ID, to: collection }));
const result_bytes = await eth_call([{ to: callable.to, input: callable.data }])(reader({ chain_id: CHAIN_ID }));
const info = callable.decode(result_bytes);
// → [Address, Uint256] Surface
| Method | Shape | Purpose |
|---|---|---|
royalty_info({ token_id, sale_price }) | Callable<{ receiver, royalty_amount }> | Per-sale royalty calc. |
Interface ID
0x2a55205a — supports detection via ERC-165.