npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zilpay/zilpay-web3

v0.0.1

Published

ZilPay Web3.js is a JavaScript library that provides a convenient way to interact with the Zilliqa blockchain and the ZilPay wallet extension. It allows developers to easily integrate Zilliqa functionality into their web applications.

Downloads

11

Readme

ZilPay Web3.js

ZilPay Web3.js is a JavaScript library that provides a convenient way to interact with the Zilliqa blockchain and the ZilPay wallet extension. It allows developers to easily integrate Zilliqa functionality into their web applications.

Installation

To use ZilPay Web3.js in your project, you can include it via a script tag or install it using npm.

npm

Install the package using npm:

npm install @zilpay/zilpay-web3
yarn add @zilpay/zilpay-web3
bun add @zilpay/zilpay-web3

Then, you can import the library in your JavaScript file:

import { initZilPayWeb3, zilPay } from 'zilpay-web3';

Initialization

This will inject into global onject the windows.zilPay. To initialize ZilPay Web3.js, call the initZilPayWeb3() function:

initZilPayWeb3();

This function checks if the ZilPay wallet extension is available and initializes the zilPay object on the global window object.

Usage

After initializing ZilPay Web3.js, you can access the zilPay object to interact with the Zilliqa blockchain and the ZilPay wallet.

Wallet

The zilPay.wallet object provides methods to interact with the user's ZilPay wallet.

Connecting to the Wallet

To connect to the user's ZilPay wallet, use the connect() method:

const isConnected = await zilPay.wallet.connect();

This method prompts the user to grant permission to your application to access their wallet.

Disconnecting from the Wallet

To disconnect from the user's ZilPay wallet, use the disconnect() method:

await zilPay.wallet.disconnect();

This method revokes the permission granted to your application to access the user's wallet.

Signing Transactions

To sign a transaction using the user's ZilPay wallet, use the sign() method:

const signedTransaction = await zilPay.wallet.sign(transaction);

This method prompts the user to sign the provided transaction using their ZilPay wallet.

Blockchain

The zilPay.blockchain object provides methods to interact with the Zilliqa blockchain.

Getting Blockchain Information

To retrieve information about the Zilliqa blockchain, use the getBlockChainInfo() method:

const blockchainInfo = await zilPay.blockchain.getBlockChainInfo();

This method returns information such as the current block number, network ID, and more.

Getting Account Balance

To retrieve the balance of a specific account, use the getBalance() method:

const balance = await zilPay.blockchain.getBalance(address);

This method returns the balance of the specified account address.

Contracts

The zilPay.contracts object provides methods to interact with smart contracts on the Zilliqa blockchain.

Deploying a Contract

To deploy a new contract, use the deploy() method:

const [transaction, contract] = await zilPay.contracts.new(code, init).deploy(params, priority);

This method deploys a new contract with the provided code and initialization parameters.

Calling a Contract Function

To call a function on a deployed contract, use the call() method:

const transaction = await contract.call(functionName, args, params, priority);

This method calls the specified function on the contract with the provided arguments and parameters.

Examples

Here are a few examples of how to use ZilPay Web3.js:

Connecting to the Wallet

async function connectToWallet() {
  const isConnected = await zilPay.wallet.connect();
  if (isConnected) {
    console.log('Connected to ZilPay wallet');
  } else {
    console.log('Failed to connect to ZilPay wallet');
  }
}

Getting Account Balance

async function getAccountBalance(address) {
  const balance = await zilPay.blockchain.getBalance(address);
  console.log(`Account balance: ${balance}`);
}

Deploying a Contract

async function deployContract(code, init, params) {
  const [transaction, contract] = await zilPay.contracts.new(code, init).deploy(params);
  console.log(`Contract deployed: ${contract.address}`);
}

Contributing

Contributions to ZilPay Web3.js are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

License

ZilPay Web3.js is released under the MIT License.