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

zbyte-relay-client

v1.1.8

Published

light weight client library to interact with the relay server

Downloads

5

Readme

Relay Client

The Relay Client provides functionalities to establish connections with the relay server, enabling operations such as smart contract deployment and invocation. Additionally, it facilitates interaction with wallets to sign transactions necessary for executing these operations.

Installation

To install the library, execute the following npm command:

    npm install @zbyteio/zbyte-relay-client

Usage

Refer to the code snippet below for integrating the client library into your project:

// define relay configuration
const relayConfig = {
  relayBaseURL: <relay server base url>, // URL for the relay service
  nativeChainId: <chain id>, // Chain ID for the native blockchain (137 for mainnet, 80002 for testnet)
  pollWait: <poll wait time in milliseconds>, // Wait time between subsequent polling calls for operation status
  pollTimeOut: <poll time out in milliseconds>, // Timeout duration for ceasing waiting on an operation
};

// create wallet interface
const wallet: IzbyteWallet // Wallet of type IzbyteWallet (refer to https://github.com/orgs/Zbyteio/packages/npm/package/zbyte-wallet-ui-sdk)

const relayClient = new RelayClient(relayConfig, wallet); // Wallet is of type IzbyteWallet as specified in interfaces

// Deploy a smart contract on a blockchain
relayClient.deployContract(
  <bytecode>, // Bytecode of the smart contract
  <contract abi>, // ABI of the smart contract
  <[contructor args]>, // Constructor arguments
  <chain id> // Chain ID of the blockchain for contract deployment
);
// returns the transaction receipt type (refer to https://docs.ethers.org/v5/api/providers/types/#providers-TransactionReceipt)

// Invoke a smart contract on a blockchain
relayClient.invokeContract(
  <function name>, // Name of the function to invoke
  <contract address> // Smart contract address on the blockchain
  <function abi>, // ABI of the function to invoke
  <[funtion parameters array]>, // Array of function parameters
  <chain id>, // Chain ID of the blockchain where the contract is deployed
// returns the transaction receipt type (refer to https://docs.ethers.org/v5/api/providers/types/#providers-TransactionReceipt)

// Transfer DPLAT tokens from one account to another
relayClient.transferDplat(
  <chain id>, // Chain ID of the blockchain where the DPLAT token contract is deployed
  <receiver address>, // Receiver's address
  <amount>, // Amount of DPLAT tokens to transfer
)
//Upon completion, it returns the workflow ID. You can then utilize the '/relay/v1/workflow/{id}/status' API from the Relay APIs to retrieve the status of the transaction

// Approve DPLAT tokens to an account to grant spending rights
relayClient.approveDplat(
  <chain id>, // Chain ID of the blockchain where the DPLAT token contract is deployed
  <spender address>, // Spender's address
  <amount>, // Amount of DPLAT tokens to approve
)
//Upon completion, it returns the workflow ID. You can then utilize the '/relay/v1/workflow/{id}/status' API from the Relay APIs to retrieve the status of the transaction

// Deposit DPLAT tokens as a credit to become payer, the payer address will be taken from his wallet
relayClient.depositDplat(
  <amount>, // Amount of DPLAT tokens to deposit
  <chainId>, // ChainId of blockchain to deposit dplat
)
//Upon completion, it returns the transaction receipt of deposit transaction

Refer to this example for guidance on using the SDK

License

MIT

For further inquiries or support, please contact [email protected].