Skip to content

Commit

Permalink
doc: Update the SDK documentation (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
alainncls authored Oct 20, 2023
1 parent 046da0c commit 506c139
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# Verax Attestation Registry - SDK

The `verax-sdk` facilitates the interactions with the contracts and the subgraph, both from a frontend and a backend.
The Verax SDK facilitates the interactions with the contracts and the subgraph, both from a frontend and a backend.

[DRAFT]

## Installation

VeraxSDK is a [npm package](https://www.npmjs.com/package/verax-sdk/).
VeraxSDK is a [npm package](https://www.npmjs.com/package/@verax-attestation-registry/verax-sdk/).

```bash
# npm
npm install --save verax-sdk
npm i @verax-attestation-registry/verax-sdk
```

```bash
# yarn
yarn add verax-sdk
yarn add @verax-attestation-registry/verax-sdk
```

```bash
# pnpm
pnpm add @verax-attestation-registry/verax-sdk
```

## Getting Started
Expand All @@ -24,35 +29,35 @@ yarn add verax-sdk

```js
// CommonJS
var VeraxSdk = require("verax-sdk");
var VeraxSdk = require("@verax-attestation-registry/verax-sdk");
```

```js
// ES6
import VeraxSdk from "verax-sdk";
import VeraxSdk from "@verax-attestation-registry/verax-sdk";
```

### 2. Instantiate VeraxSdk

```js
// Default configuration for Linea Testnet
const veraxSdk = new VeraxSdk(VeraxSdk.LineaConfTestnet);
const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_TESTNET);
```

or,

```js
// Default configuration for Linea Mainnet
const veraxSdk = new VeraxSdk(VeraxSdk.LineaConfMainnet);
const veraxSdk = new VeraxSdk(VeraxSdk.DEFAULT_LINEA_MAINNET);
```

or,

```js
// Custom configuration
const myVeraxConfiguration = {
rpcUrl: "https://my.rpc.url",
chain: 12345,
chain: lineaTestnet,
mode: SDKMode.BACKEND,
subgraphUrl: "https://my.subgraph.url",
portalRegistryAddress: "0xMyPortalRegistryAddress",
moduleRegistryAddress: "0xMyModuleRegistryAddress",
Expand All @@ -69,10 +74,10 @@ const veraxSdk = new VeraxSdk(myVeraxConfiguration);
```js
// Each Verax classes has its DataMapper
// Get them from the SDK instance
const portalDataMapper = veraxSdk.portalDataMapper; // RW Portals
const schemaDataMapper = veraxSdk.schemaDataMapper; // RW Schemas
const moduleDataMapper = veraxSdk.moduleDataMapper; // RW Modules
const attestationDataMapper = veraxSdk.attestationDataMapper; // RW Attestations
const portalDataMapper = veraxSdk.portal; // RW Portals
const schemaDataMapper = veraxSdk.schema; // RW Schemas
const moduleDataMapper = veraxSdk.module; // RW Modules
const attestationDataMapper = veraxSdk.attestation; // RW Attestations
```

### 2. Read content (one object)
Expand Down

0 comments on commit 506c139

Please sign in to comment.