Git Product home page Git Product logo

ocex-api's Introduction

Disclaimer

πŸ’€ This is a Work in Progress.
Current status: Common PoC data storage and methods available. Partially tested.
Use at your own risk.

🎟️ ✨ OCEX API Client 🎁 πŸ‘›

OCEX smartcontract api for interaction with an OCEX smartcontract.

Features

  • For Owners
    • publish new instance of a contract to a blockchain
    • top-up balance of an instantiated contract
    • add new coupons
    • burn coupons
    • check spare funds on a smartcontract
    • withdraw spare funds
    • transfer ownership of a contract
  • For Clients
    • activate a coupon
    • сheck a coupon

Install && Usage

yarn add https://github.com/bsn-si/ocex-api
# or 
npm i --save https://github.com/bsn-si/ocex-api

Simple node usage

import { cryptoWaitReady } from "@polkadot/util-crypto"
import { ApiPromise, WsProvider } from "@polkadot/api"
import { Keyring } from "@polkadot/keyring"

// Import contract api class
import { Ocex } from "ocex-api"

async function main() {
  await cryptoWaitReady()
  
  const keyring = new Keyring({ type: "sr25519" })

  // Initialise the provider to connect to the local node
  const provider = new WsProvider("ws://127.0.0.1:9944")
  const client = await ApiPromise.create({ provider })

  // Common owner keys
  const signer = keyring.addFromUri("//Alice")
  console.log("Signer: ", signer.address)

  // Instance from exists contract address 
  const contract = await Ocex.fromAddress(client, signer, "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty")
  
  // Other actions..
}

For more detauls check out our example of usage. For run example:

npm run run:example

Coupon activation method

Now module doesn't have package on npm, and have dependency of wasm module. You need install package by your target & assign method to class instance.

NodeJS

# Package for use from nodejs
yarn add https://gitpkg.now.sh/bsn-si/ocex-coupon-signature/pkg_node?main

# Package for use from web (with webpack)
yarn add https://gitpkg.now.sh/bsn-si/ocex-coupon-signature/pkg_web?main

And for initialization

// Import for nodejs
import { get_coupon_signature } from "ocex-coupon-signature-node"
// Import for web with webpack
import { get_coupon_signature } from "ocex-coupon-signature-web"

// ...

const contract = await Ocex.fromAddress(client, signer, "...")

// Setup method for create signature
contract.get_coupon_signature = get_coupon_signature

Related repos

License

Apache License 2.0 Β© Bela Supernova (bsn.si)

ocex-api's People

Contributors

friktor avatar dsrdrk11a avatar

Stargazers

Dmitrii Putilov avatar

Watchers

 avatar Dmitrii Putilov 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.