Skip to content

JavaScript SDK to manage and interact with the safient contracts (Claims, Incentivization) on Safient protocol

License

Notifications You must be signed in to change notification settings

safient/contract-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2d88223 · Nov 14, 2022

History

69 Commits
Nov 14, 2022
Sep 14, 2022
Oct 29, 2021
Sep 6, 2021
Nov 14, 2022
Sep 14, 2022
Sep 14, 2022
Oct 5, 2021
May 31, 2021
Sep 14, 2022
Sep 28, 2021
Sep 8, 2022
Aug 26, 2021
Nov 14, 2022
Sep 14, 2022
Oct 5, 2021

Repository files navigation

Safient Contracts SDK

JavaScript SDK to manage and interact with the safe claims on Safient protocol.

Local installation

  git clone https://github.com/safient/safient-contract-js.git
  cd safient-contract-js
  npm install

Running tests

Create a .env file in the root directory with INFURA_API_KEY for mainnet or testnet deployment.

Testing the contracts

  npm run test:contract

Testing the JS SDK

Run a local blockchain

  npm run chain

Deploy the contract, run the test on a different terminal

  npm run deploy:sdk
  npm run test:sdk

Testing the contract & SDK

  npm run deploy:sdk
  npm run test

Getting started

  npm i @safient/contracts

Usage

// If not injected web3 provider, create a jsonRpcProvider
const { JsonRpcProvider } = require('@ethersproject/providers');
const provider = new JsonRpcProvider('http://localhost:8545');

// Get signer and chainId from provider
(async () => {
  const signer = await provider.getSigner();
  const providerNetwork = await provider.getNetwork();
  const chainId = providerNetwork.chainId;
})();

Initialization

import { SafientMain, Arbitrator, Types } from '@safient/contracts';

const safientMain = new SafientMain(signer, chainId);
const arbitrator = new Arbitrator(signer, chainId);

Building docs

Update the docs markdown

npm run build:docs

Run the docusaurus website locally

npm run serve:docs