@zilliqa-js/zilliqa
TypeScript icon, indicating that this package has built-in type declarations

3.5.0 • Public • Published

@zilliqa-js/zilliqa

JavaScript library for interacting with the Zilliqa blockchain.

Table of Contents

Installation

npm install @zilliqa-js/zilliqa --save

or

yarn add @zilliqa-js/zilliqa

Usage

First, you need to import the library:

const { Zilliqa } = require("@zilliqa-js/zilliqa");

or using ES6 imports:

import { Zilliqa } from "@zilliqa-js/zilliqa";

Then, create an instance:

const zilliqa = new Zilliqa("https://api.zilliqa.com");

Examples

Sending a Transaction

const myAddress = "Your Zilliqa Address";
const recipient = "Recipient Zilliqa Address";
const amount = Zilliqa.utils.units.toQa("1", Zilliqa.utils.units.Units.Zil);

const tx = await zilliqa.blockchain.createTransaction({
  toAddr: recipient,
  amount: amount,
  gasPrice: "2000",
  gasLimit: "1",
});

console.log(`Transaction ID: ${tx.id}`);
console.log(
  `After sending, your new balance is: ${await zilliqa.blockchain.getBalance(
    myAddress
  )}`
);

Fetching Account Balance

const myAddress = "Your Zilliqa Address";
const balance = await zilliqa.blockchain.getBalance(myAddress);
console.log(`Your balance is: ${balance}`);

Documentation

For in-depth documentation, please refer to Zilliqa Official Documentation.

License

This project is licensed under the GPL License. See LICENSE for details.

/@zilliqa-js/zilliqa/

    Package Sidebar

    Install

    npm i @zilliqa-js/zilliqa

    Weekly Downloads

    556

    Version

    3.5.0

    License

    GPL-3.0

    Unpacked Size

    58.4 MB

    Total Files

    18

    Last publish

    Collaborators

    • lukozill
    • troelsfr
    • inamirandaz
    • zilliqateam
    • fluffypancake5436
    • zilliqaofficial