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

elderjs

v1.0.9

Published

JS lib to enable frontend for Rollapps connected to Elder Ecosystem

Downloads

642

Readme

ElderJS

Version License GitHub issues

ElderJS is a JavaScript library designed to facilitate the integration of Rollapps with the Elder Ecosystem. It enables seamless interaction with the Elder blockchain, wallet connection via Keplr, and the ability to create, sign, and broadcast custom transactions.


📚 Table of Contents


📖 Introduction

ElderJS provides developers with a simple and effective way to connect to Rollapps on the Elder blockchain. It enables wallet connection, custom transaction generation, and broadcasting functionalities using Keplr and CosmJS. This library aims to reduce the complexity of interacting with Elder's Rollapp ecosystem and streamline dApp development.


Features

  • 🔗 Keplr Wallet Integration: Easily connect and manage wallet interactions.
  • 🚀 Custom Transaction Support: Create and send custom transactions specific to Elder's Rollapp ecosystem.
  • ⚙️ Custom Fees & Gas Management: Set custom fees and gas limits for Rollapp transactions.
  • 📡 RPC and REST Integration: Interact with Elder nodes via RPC and REST endpoints.

📦 Installation

Install ElderJS via npm:

npm install elderjs

🚀 Usage

1️⃣ Initialize Elder Client

To initialize the Elder client and connect to a Rollapp using Keplr, use the getElderClient function.

import { getElderClient } from 'elderjs';

const elderChainConfig = {
  chainName: 'your-chain-name',
  rpc: 'https://your-rpc-url',
  rest: 'https://your-rest-url',
  rollID: 11,
};

(async () => {
  const { elderAddress, elderClient } = await getElderClient(elderChainConfig);
  console.log('Connected address:', elderAddress);
})();

Note: Keplr must be installed and enabled.


2️⃣ Create and Send Custom Transaction

To create and broadcast a custom transaction on a Rollapp, use the getElderMsgAndFee and sendElderCustomTransaction functions.

import { getElderClient, getElderMsgAndFee, sendElderCustomTransaction } from 'elderjs';

(async () => {
  const { elderAddress, elderClient } = await getElderClient(elderChainConfig);

  const tx = {
    to: '0xRecipientAddress',
    value: ethers.utils.parseEther('0.01'),
  };

  const { elderMsg, elderFee } = getElderMsgAndFee(
    tx,
    elderAddress,
    200000, // gas limit
    ethers.utils.parseEther('0.01'),
    1, // rollapp-chainId
    11 // elder-rollapp-id
  );

  await sendElderCustomTransaction(elderAddress, elderClient, elderMsg, elderFee);
})();

Note: Replace the to, value, and other transaction details with your own custom values.


📂 File Structure

elderjs/
├── chains.js                 # Chain configuration file
├── elder_proto/              # Protobuf files for custom messages
│   └── dist/
│       └── router/tx.js      # Compiled protobuf definitions for Rollapp messages
├── index.js                  # Main entry point for ElderJS
└── package.json              # Package metadata and dependencies

⚙️ Configuration

To connect to a Rollapp, you'll need to provide the following chain configuration:

const elderChainConfig = {
  chainName: 'your-chain-name', // The chain name to connect to
  rpc: 'https://your-rpc-url',  // The RPC endpoint
  rest: 'https://your-rest-url' // The REST endpoint
  rollID: 11                    // The elder-rollapp-id
};

This configuration is required when calling getElderClient.


📚 Function Reference

🔹 getElderClient(elderChainConfig)

Description: Initializes a connection to a Rollapp via Keplr and returns an elderAddress and elderClient.

Parameters:

  • elderChainConfig (object) — Contains chainName, rpc, and rest configuration.

Returns:

  • { elderAddress, elderClient } — The connected wallet address and client instance.

Example:

const { elderAddress, elderClient } = await getElderClient(elderChainConfig);

🔹 sendElderCustomTransaction(elderAddress, elderClient, elderMsg, elderFee)

Description: Sends a custom transaction to the Rollapp.

Parameters:

  • elderAddress (string) — The connected wallet address.
  • elderClient (object) — The Elder client instance.
  • elderMsg (object) — Custom message to be sent.
  • elderFee (object) — Custom fee information.

Example:

await sendElderCustomTransaction(elderAddress, elderClient, elderMsg, elderFee);

🔹 getElderMsgAndFee(tx, elderAddress, gasLimit, value, chainId, rollID)

Description: Prepares the custom transaction message and fee required for Elder Rollapp transactions.

Parameters:

  • tx (object) — Transaction details.
  • elderAddress (string) — The sender's address.
  • gasLimit (number) — The gas limit for the transaction.
  • value (string) — The transaction value.
  • chainId (number) — The chain ID.
  • rollID (string) — Roll ID for the transaction.

Returns:

  • { elderMsg, elderFee } — The message and fee for the transaction.

Example:

const { elderMsg, elderFee } = getElderMsgAndFee(tx, elderAddress, 200000, ethers.utils.parseEther('0.01'), 1, 'roll-id-example');

📋 Dependencies


🐞 Issues

If you encounter any issues, please report them via GitHub Issues:

🔗 Report an Issue


📜 License

This project is licensed under the ISC License.


If you found ElderJS useful, feel free to ⭐️ the repository to support development.

🔗 GitHub Repository


If you'd like additional sections, such as examples, contributing guidelines, or advanced usage, let me know.