Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Update the SDK documentation #308

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading