NPM SDK¶
The @ethsign/sp-sdk package works in frontend and Node backend projects:
It has two clients. SignProtocolClient registers schemas and creates and revokes attestations; IndexService reads them from the SignScan indexer. Release notes are in the package's changelog.
Writing data: SignProtocolClient¶
Parameters¶
| Name | Type | Description |
|---|---|---|
| spMode | SpMode |
On-chain or Arweave (off-chain) mode. |
| options | OnChainClientOptions, OffChainClientOptions |
Client options based on spMode. |
Warning
account in options is optional. Without it, the SDK takes the account from the window.ethereum provider; if there is no provider either, SDK calls fail.
Example¶
const { privateKeyToAccount } = require("viem/accounts");
const client = new SignProtocolClient(SpMode.OnChain, {
chain: EvmChains.baseSepolia,
account: privateKeyToAccount(privateKey),
apiKey: 'xxx', // Get a key from https://developer.sign.global/
});
Reading data: IndexService¶
Parameters¶
| Name | Type | Description |
|---|---|---|
| env | testnet, mainnet |
Whether the indexing service queries testnets or mainnets. |
Example¶
import { IndexService } from "@ethsign/sp-sdk";
async function getSchemaListFromIndexService() {
const indexService = new IndexService("testnet");
const res = await indexService.querySchemaList({ page: 1 });
}
async function getSchemaFromIndexService() {
const indexService = new IndexService("testnet");
const res = await indexService.querySchema("onchain_evm_80001_0x1");
}
async function getAttestationListFromIndexService() {
const indexService = new IndexService("testnet");
const res = await indexService.queryAttestationList({ page: 1 });
}
async function getAttestationFromIndexService() {
const indexService = new IndexService("testnet");
const res = await indexService.queryAttestation("onchain_evm_80001_0x1");
}
Next¶
- Schemas and Attestations: the write API
- Querying: the read API
- Examples: end-to-end scripts for on-chain and Arweave modes