Giter Club home page Giter Club logo

complydefi-sdk's Introduction

COMPLYDEFI SDK

This package facilitates the interaction with ComplyDefi stored in the BlockChain.

Specifications

Features

  • Validate wallet address compliance
  • Get required claims

BlockChain Provider

To interact with the BlockChain, you will need to instantiate a Provider.

The SDK is using Ethers to connect with Ethereum network. Thus, any provider supported by Ethers can be used with the SDK. This means any standard web3 provider should by supported.

Connect to a default provider:

// You can use any standard network name
//  - "homestead"
//  - "rinkeby"
//  - "ropsten"
//  - "kovan"
const ethers = require('ethers');

const provider = ethers.getDefaultProvider('ropsten');

const complyDefi = await Complydefi.at('0x...', {provider});

Connect to JSON RPC:

// When using the JSON-RPC API, the network will be automatically detected
// Default: http://localhost:8545
let httpProvider = new ethers.providers.JsonRpcProvider();

Connect to any Web3 Provider:

// When using a Web3 provider, the network will be automatically detected

// e.g. HTTP provider
let currentProvider = new web3.providers.HttpProvider('http://localhost:8545');

let web3Provider = new ethers.providers.Web3Provider(currentProvider);

Connect to metamask:

// The network will be automatically detected; if the network is
// changed in MetaMask, it causes a page refresh.

let provider = new ethers.providers.Web3Provider(web3.currentProvider);

Examples

Get required claims

const { ComplyDefiSDK } = require('@onchain-id/complydefi-sdk');

const provider = new ethers.providers.JsonRpcProvider();

(async () => {
    const complyDefi = new ComplyDefiSDK.ComplyDefi('0xadD92F8Ef0729E969c5a98Ea5740c9b644B362e3', { provider });

    const claims = await complyDefi.getRequiredClaims();

    console.log(claims); // ['claim1', 'claim2']
})();

Check compliance of wallet address

const { ComplyDefiSDK } = require('@onchain-id/complydefi-sdk');

const provider = new ethers.providers.JsonRpcProvider();

(async () => {
  const complyDefi = new ComplyDefiSDK.ComplyDefi('0xadD92F8Ef0729E969c5a98Ea5740c9b644B362e3', { provider });

  const isComply = await complyDefi.isComply('0xasfgdsgd...dsasd');
  
  console.log(isComply); // true or false
})();

Development

  • Install dependencies: npm i.
  • Lint code with npm run lint lint.
  • Run unit tests: npm run test:unit. You can run unit tests each time you modify a file with npm run test:unit:watch.
  • Build project with npm run build. This will build package into the dist/ folder from the TypeScript sources.
  • Run end to end tests against a builded package: npm run test:e2e.

complydefi-sdk's People

Contributors

cyrilledec avatar joachim-lebrun avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.