GithubHelp home page GithubHelp logo

meneter / ineryjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from inery-blockchain/ineryjs

0.0 0.0 0.0 900 KB

Javascript API for integration with Inery-based blockchains using Inery RPC API.

JavaScript 70.75% CSS 29.25%

ineryjs's Introduction

ineryjs

Javascript API for integration with Inery-based blockchains using Inery RPC API.
Documentation can be found in docs folder.

Import

Browser

Run command npm run build-web. Then copy folder dist-web in your project folder. Import scripts in your HTML file and use it. See Module in browser tutorial for more.

ES Modules

import { Api, JsonRpc, RpcError, JsSignatureProvider } from 'ineryjs';

CommonJS

const { Api, JsonRpc, RpcError, JsSignatureProvider } = require('ineryjs');

Basic Usage

Signature Provider

The Signature Provider holds private keys and is responsible for signing transactions. Using the JsSignatureProvider in the browser is not secure and should only be used for development purposes. Use a secure vault outside of the context of the webpage to ensure security when signing transactions in production

const user1PrivateKey = "5JRchd5OZaHl9DAuVPEMo0gEx5nYiGc0Tn2aB75ef96FjuOiq"; // user1 private key
const signatureProvider = new JsSignatureProvider([user1PrivateKey]);

JsonRpc

Open a connection to JsonRpc.

const url="https://www.myurl.com";
const rpc = new JsonRpc(url);

API

You may exclude these when running in a browser since most modern browsers now natively support these. If your browser does not support these, then you can import them as a dependency through the following deprecated npm package.

const api = new Api({ rpc, signatureProvider });

Sending a transaction

transact() is used to sign and push transactions onto the blockchain with an optional configuration object parameter. Given no configuration options, transactions are expected to be unpacked with TAPOS fields (expiration, ref_block_num, ref_block_prefix) and will automatically be broadcast onto the chain.

(async () => {
  const result = await api.transact({
    actions: [{
      account: 'inery.token',
      name: 'transfer',
      authorization: [{
        actor: 'user1',
        permission: 'active',
      }],
      data: {
        from: 'user1',
        to: 'user2',
        quantity: '0.0001 INR',
        memo: ''
      }
    }]
  });
  console.log(result);
})();

Documentation

When you install module, open index.html file in docs directory to see documentation.

ineryjs's People

Contributors

inery-admin avatar meneter 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.