Querying
Schemas
Querying schemas
async function querySchemaList(query: {
id?: string;
registrant?: string;
mode?: "offchain" | "onchain";
page: number;
size?: number;
}): Promise<
PageInfo & {
rows: SchemaInfo[];
}
>;
Parameters
| Name |
Type / Value |
Description |
| id? |
string |
The schema ID you are querying for. |
| registrant? |
string |
Find schemas 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
| Name |
Type |
Description |
| 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
| Name |
Type / Value |
Description |
| 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
| Name |
Type |
Description |
| attestationId |
string |
The ID of the attestation 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
| Name |
Type / Value |
Description |
| 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
import { decodeOnChainData, DataLocationOnChain } 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)
);