0.0.27-new • Published 6 months ago

@peke65/attest-sdk v0.0.27-new

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

AttestSDK

AttestSDK is a JavaScript library for interacting with the Attest API, enabling easy management of schemas within the Solana blockchain.

Installation

You can install the package via npm:

npm install @attestprotocol/sdk

Usage

To use the SDK, you need to import it and create an instance of the AttestSDK class:

import AttestSDK from '@attestprotocol/sdk';

async function run() {
  const secretKey = [/* your secret key here */];

  const client = await AttestSDK.initializeSolana({
    url,
    walletOrSecretKey: secretKey,
  })
  
  const { data: schema, error: schemaError } = await client.createSchema({
    schemaName: 'test-schema',
    schemaContent: 'string name, string email, uint8 verification_level',
    revocable: true,
    levy: {
      amount: new anchor.BN(10),
      asset: mintAcount,
      recipient: authorityKeypair.publicKey,
    },
  })

  console.log({ schema });

  const fetchSchema = await client.fetchSchema(schema!)

  console.log({ fetchSchema })
}

run();

Features

  • Register Schema: Register a new schema with a name and content.
  • Fetch Schema: Retrieve an existing schema by its ID.
  • Create Attestation: Create an attestation based on a schema.
  • Revoke Attestation: Revoke an attestation.

Running Tests

Solana Tests

yarn test-solana

Stellar Tests

Stellar tests require funded accounts on the Stellar Testnet and access to deployed Soroban contracts. Before running the tests:

  1. Fund the test accounts using the Stellar Friendbot:

  2. Verify contract deployment:

    • The default Protocol Contract ID is: CBPL7XR7NNPTNSIIFWQMWLSCX3B3MM36UYX4TW3QXJKTIEA6KDLRYAQP
    • The default Authority Contract ID is: CDQREK6BTPEVD4O56XR6TKLEEMNYTRJUG466J2ERNE5POIEKN2N6O7EL
    • You can override these addresses using command-line arguments (see below)
  3. Run the tests:

yarn test-stellar

Command-line options:

  • --force-continue: Bypass the funding check (test will likely fail with unfunded accounts)
  • --protocol=<address>: Override the protocol contract address
  • --authority=<address>: Override the authority contract address
  • --token=<address>: Set a token contract address for authority initialization
  • --testnet: Specify that you're using the Stellar testnet
# Example with custom contracts
yarn test-stellar -- --protocol=CBFL7XR7NNPTNSIIFWQMWLSCX3B3MM36UYX4TW3QXJKTIEA6KDLRYAQZ --authority=CDQR4K6BTPEVD4O56XR6TKLEEMNYTRJUG466J2ERNE5POIEKN2N6O7EM
0.0.24-new

6 months ago

0.0.22

6 months ago

0.0.24

6 months ago

0.0.24-fix

6 months ago

0.0.25-new

6 months ago

0.0.15

7 months ago

0.1.2-alpha

6 months ago

0.0.16

7 months ago

0.0.20-pre

6 months ago

0.0.17

7 months ago

0.1.0-alpha

6 months ago

0.0.18

6 months ago

0.0.19

6 months ago

0.0.26-stable

6 months ago

0.0.25-stable

6 months ago

0.0.11

7 months ago

0.0.26-new

6 months ago

0.0.12

7 months ago

0.0.13

7 months ago

0.0.14

7 months ago

0.0.21-pre

6 months ago

0.1.0

7 months ago

0.0.23-pre

6 months ago

0.0.27

6 months ago

0.0.27-new

6 months ago

0.0.22-pre

6 months ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago