Coder Social home page Coder Social logo

ivan801 / dharma.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dharmaprotocol/dharma.js

0.0 0.0 0.0 8.78 MB

DEPRECATED: Javascript Developer library for interacting with Dharma Protocol

Home Page: https://dharma.io

License: MIT License

TypeScript 99.77% Shell 0.11% JavaScript 0.12%

dharma.js's Introduction

NOTE: dharma.js is deprecated and no longer in active maintenance. Please email [email protected] if you have any questions or concerns


Hello, dharma.js!

CircleCI

This repository contains the dharma.js client application development libraries. dharma.js makes it easy for developers who may not be deeply familiar with smart contract development to interact with the various components of Dharma protocol and build hyper-flexible lending applications.

For more information, please check out the Dharma Developer Portal.

Getting Started with Dharma.js

Installing Dharma.js

Add Dharma.js to your project using yarn:

yarn add @dharmaprotocol/dharma.js

Alternatively, add Dharma.js to your project using npm:

npm install @dharmaprotocol/dharma.js --save

Importing Dharma.js

Include Dharma.js in your project code using ES6 style imports (recommended):

import { Dharma } from "@dharmaprotocol/dharma.js";

Alternatively, include Dharma.js in your project code using require syntax:

const { Dharma } = require("@dharmaprotocol/dharma.js");

Instantiating Dharma.js

In order to instantiate Dharma.js, you need to specify a web3 provider.

The web3 provider can either be instantiated directly, or pulled from the browser's window object.

Instantiating the web3 provider directly

You'll want to instantiate a web3 provider directly if you're:

  • running Dharma.js on a backend
  • working with a local blockchain

You'll first import Dharma and Web3 from the Dharma.js package:

import { Dharma, Web3 } from "@dharmaprotocol/dharma.js";

Assuming you're running a local blockchain on localhost port 8545, you'd specify the provider as follows:

const host = "http://localhost:8545";
const provider = new Web3.providers.HttpProvider(host);

You'd then pass the above provider to the Dharma constructor, using JavaScript's new operator to construct an instance of Dharma connected to your local blockchain:

const dharma = new Dharma(provider);

Pulling the web3 provider off the browser's window object

If the user is interacting with your dApp via a web3 wallet (e.g., MetaMask, Coinbase Wallet, etc.), you can pull the web3 provider from the browser's window object and pass that to the Dharma constructor:

const provider = window.web3.currentProvider;

const dharma = new Dharma(provider);

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.