Create, manage and interact with SNS Optics categories on-chain
SNS Categories is a Solana program for managing SNS Optics categories. It provides functionalities to create a new category, add members to an existing category, and remove members from a category. It's currently in beta and open for contributions from the community.
- Create category: Enables the creation of a new category on Solana Name Service.
- Add member: Allows the addition of a new member to an existing category.
- Remove member: Allows the removal of a member from an existing category.
Belonging to a category is equivalent to the category member being a child (or subdomain) of the category metadata. In order to check if a .sol domain is part of a category, you need to follow these steps:
-
Derive the category public key: You can derive the category public key by using the category name and the appropriate hashing method provided by the program
-
Derive the category member public key associated with the domain: You can derive the category member public key by using the domain name and the category public key obtained in the previous step
-
Check the on-chain data: Query the on-chain data for the derived category member public key. If the account is present, it indicates that the domain is part of the category.
All members of a category can be retrieved via a getProgramAccount
RPC request and the following filters:
const filters: MemcmpFilter[] = [
{
memcmp: {
offset: 0,
bytes: category.toBase58(),
},
},
{
memcmp: {
offset: NameRegistryState.HEADER_LEN,
bytes: ((Tag.CategoryMember as number) + 1).toString(),
},
},
];
All categories can be retrieved via a getProgramAccount
RPC request and the following filters:
const filters: MemcmpFilter[] = [
{
memcmp: {
offset: 0,
bytes: CATEGORY_TLD.toBase58(),
},
},
{
memcmp: {
offset: NameRegistryState.HEADER_LEN,
bytes: (Tag.CategoryMetadata + 1).toString(),
},
},
];
A reproducible build script (build.sh
) can be used to build the program using docker
For security disclosures or to report a bug, please visit ImmuneFi for more information on our bug bounty program.