Usage & Examples
Schemas
Querying Schemas
async function querySchemaList(query: {
id?: string;
registrant?: string;
mode?: "offchain" | "onchain";
page: number;
size?: number;
}): Promise<
PageInfo & {
rows: SchemaInfo[];
}
>;Parameters
id?
string
The schema ID you are querying for.
registrant?
string
Find schemas that were created by a specific registrant address.
mode?
offchain, onchain
The schema's location.
page
number
The page to fetch.
size?
number
The number of results to return.
Example
const res = await indexService.querySchemaList({
id: "onchain_evm_11155111_0xd",
registrant: "0x526dDf0Cc975E0b5B039c85b5cD7ba1e1300500e",
mode: "onchain",
page: 1,
size: 2,
});Getting a Schema By ID
async function querySchema(schemaId: string): Promise<SchemaInfo | null>;Parameters
schemaId
string
The ID of the schema to retrieve.
Example
const res = await indexService.querySchema("onchain_evm_11155111_0xd");Attestations
Querying Attestations
async function queryAttestationList(query: {
id?: string;
schemaId?: string;
attester?: string;
page: number;
mode?: "offchain" | "onchain";
indexingValue?: string;
}): Promise<
PageInfo & {
rows: AttestationInfo[];
}
>;Parameters
id?
string
The attestation ID you are querying for.
schemaId?
string
Find attestations that belong to a specific schema ID.
attester?
string
Find attestations that a specific attester created.
page
number
The page to fetch.
mode?
offchain, onchain
The attestation's location.
indexingValue?
string
Find attestations with a specific indexing value.
Example
const res = await indexService.queryAttestationList({
id: "",
schemaId: "",
attester: "",
page: 1,
mode: "onchain",
indexingValue: "",
});Getting an Attestation By ID
async function queryAttestation(
attestationId: string
): Promise<AttestationInfo | null>;Parameters
attestationId
string
The ID of the schema to retrieve.
Example
const res = await indexService.queryAttestation("onchain_evm_11155111_0x5");Utils
Decoding Attestation Data
function decodeOnChainData(
data: any,
dataLocation: DataLocationOnChain,
schemaData: SchemaItem[]
): any;Parameters
data
string
The hex string retrieved from an onchain attestation object.
DataLocationOnChain
DataLocationOnChain
Location of the data. Either ONCHAIN, ARWEAVE, or IPFS.
schemaData
string
The data string of the schema that this attestation belongs to.
Example
const { decodeOnChainData } from "@ethsign/sp-sdk";
const attestationData = "0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000b1987e041b79727cd2a190b53d86c2d1cd2869ef0000000000000000000000000000000000000000000000000000000000000012486f6d65776f726b2f446166742050756e6b0000000000000000000000000000";
const schemaData = `[{"name":"contractDetails","type":"string"},{"name":"signer","type":"address"}]`;
const res = decodeOnChainData(
attestationData,
DataLocationOnChain.ONCHAIN,
JSON.parse(schemaData)
);Last updated
Was this helpful?
