Giter Club home page Giter Club logo

zilwrap-sdk's Introduction

zilwrap-sdk

Introduction - ZRC2 Wrapper Contract

The ZRC2 contract locks $ZIL and returns a ZRC2 compliance token to the user. If the user wishes to unwrap, the ZRC2 contract would deduct the ZRC2 tokens and returns the locked $ZIL.

Getting Started

npm install
npm run build

Initialize Zilwrap

Create a new example.js file and import zilwrap:

const { Network } = require('./lib/constants');
const Zilwrap = require('./lib/index').Zilwrap;

async function main() {
    // only declare those fields that you wish to override
    const settings = {
        gasPrice: 2000000000, // in Qa
        gasLimit: 25000
    }

    // settings is optional
    const zilwrap = new Zilwrap(Network.Testnet, 'private_key', settings);

    try {
        await zilwrap.init();
        await zilwrap.wrap('10');
        await zilwrap.transfer('recipient_address', 'token_amt');
        await zilwrap.unwrap('5');
    } catch (err) {
        console.log(err);
    }
}

main();

Deployment

For npm distribution, configure the contracts address in src/constants.ts:

export const WRAPPER_CONTRACT: { [key in Networks]: string } = {
  [Network.Mainnet]: '',
  [Network.Testnet]: 'zil1r9lexrfs44555yj8t0tuyjk8z3an0h4dv2qv2l',
  [Network.Isolated]: 'zil17qh89yvllqt63dwd4hexx758kcw8lu75z3hzzf',
};

Deployed contracts

Network Address
Testnet zil1x9hgf0rle7kgrfzpetyqgkpy997wcfxwtjsamq
Mainnet zil1gvr0jgwfsfmxsyx0xsnhtlte4gks6r3yk8x5fn

API Documentation

Refer to API Documentation for methods details.

Formatting

npm run lint
npm run lint:fix

Tests

Unit tests are located at test/test.ts.

npm run build
npm run test

zilwrap-sdk's People

Contributors

teye avatar bb111189 avatar

Stargazers

bdev avatar Xalkan Duarte avatar xiaohuo avatar

Watchers

James Cloos avatar Max Conway avatar  avatar Pablo Suarez avatar Amrit Kummer avatar  avatar Edison avatar  avatar Ovidiu Miclea avatar xiaohuo avatar Kaustubh Shamshery avatar James Hinshelwood avatar Georgiy Komarov avatar Sasha Zezulinsky avatar Mauro Medda avatar ansnunez 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.