Giter Site home page Giter Site logo

lanlan3322 / kleros-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kleros/kleros-api-deprecated

0.0 1.0 0.0 3.19 MB

A Javascript library that makes it easy to build relayers and other DApps that use the Kleros protocol.

License: MIT License

JavaScript 99.80% Shell 0.20%

kleros-api's Introduction

Kleros API

NPM Version Build Status Coverage Status Dependencies Dev Dependencies Tested with Jest JavaScript Style Guide Styled with Prettier Conventional Commits Commitizen Friendly

This repository contains a Javascript library that provides methods to interact with Kleros arbitrator and Arbitrable contracts. It can be used to develop Relayers or DApps that use Kleros smart contracts.

Installation

yarn add kleros-api

Basic Usage

See the full API docs here.

The base Kleros object initializes all of the different kleros api's with the contract addresses you pass. This object is useful if your application interacts with both arbitrators, arbitrable contracts and uses an off chain store to provide metadata on the different disputes for the UI.

// pay arbitration fee.
import Kleros from 'kleros-api'

const KlerosInstance = new Kleros(
  ETH_PROVIDER, // ethereum provider object
  KLEROS_STORE_URI, // uri of off chain storage e.g. https://kleros.in
  ARITRATOR_CONTRACT_ADDRESS, // address of a deployed Kleros arbitrator contract
  ARBITRABLE_CONTRACT_ADDRESS // address of a deployed arbitrable transaction contract
)

KlerosInstance.arbitrable.payArbitrationFeeByPartyA() // pay arbitration fee for an arbitrable contract

You can also use the specific api that best suits your needs.

// deploy a new contract and pay the arbitration fee.
import ArbitrableTransaction from 'kleros-api/contracts/implementations/arbitrable/ArbitrableTransaction'

// deploy methods are static
const contractInstance = ArbitrableTransaction.deploy(
    "0x67a3f2BB8B4B2060875Bd6543156401B817bEd22", // users address
    0.15, // amount of ETH to escrow
    "0x0", // hash of the off chain contract
    "0x3af76ef44932695a33ba2af52018cd24a74c904f", // arbitrator address
    3600, // number of seconds until there is a timeout
    "0x0474b723bd4986808366E0DcC2E301515Aa742B4", // the other party in the contract
    "0x0", // extra data in bytes. This can be used to interact with the arbitrator contract
    ETH_PROVIDER, // provider object to be used to interact with the network
  )

const address = contractInstance.address // get the address of your newly created contract

const ArbitrableTransactionInstance = new ArbitrableTransaction(address) // instantiate instance of the api

ArbitrableTransactionInstance.payArbitrationFeeByPartyA() // pay arbitration fee

Development

If you want to contribute to our api or modify it for your usage

Setup

We assume that you have node and yarn installed.

yarn install

Test

yarn ganache
yarn test

Build

yarn run build

kleros-api's People

Contributors

satello avatar n1c01a5 avatar epiqueras avatar eburgos avatar gitter-badger avatar

Watchers

James Cloos 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.