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

@kaiachain/web3js-ext

v1.0.0

Published

web3.js extension for kaiachain blockchain

Downloads

217

Readme

Web3.js Extension for kaia

Web3.js Extension for kaia offers:

  • Drop-in replacement to new Web3(...) that supports both Ethereum and kaia transaction types involving AccountKey and TxTypes. See Modifications to the Web3 object section for details

Install

Node.js

  • Install
    npm install --save @kaiachain/web3js-ext
  • ESM or TypeScript
    import { Web3 } from "@kaiachain/web3js-ext";
    const web3 = new Web3("https://public-en-baobab.klaytn.net");
  • CommonJS
    const { Web3 } = require("@kaiachain/web3js-ext");
    const web3 = new Web3("https://public-en-baobab.klaytn.net");

Browser

It is not recommended to use CDNs in production, But you can use below for quick prototyping.

<script src="https://cdn.jsdelivr.net/npm/@kaiachain/web3js-ext@latest/dist/web3js-ext.bundle.js"></script>
<script>
const web3 = new web3_ext.Web3(window.klaytn);
</script>

Usage

See example and test.

Modifications to the Web3 object

See DESIGN for source code organization.

Accounts

  • Following functions can handle Klaytn TxTypes. See src/account/index.ts
    // account independent functions
    web3.eth.accounts.recoverTransaction(rlp)
    web3.eth.accounts.signTransaction(obj or rlp)
    web3.eth.accounts.signTransactionAsFeePayer(obj or rlp)
    
    // account-bound functions
    var account = web3.eth.accounts.create()
    var account = web3.eth.accounts.privateKeyToAccount(priv)
    var account = web3.eth.accounts.decrypt(keystore)
    account.signTransaction(obj or rlp)
    account.signTransactionAsFeePayer(obj or rlp)
  • Following functions can handle the KIP-3 Klaytn keystore format v4
    web3.eth.accounts.decrypt(keystore)
    web3.eth.accounts.decryptList(keystore)

Eth RPC wrappers

  • Following functions calls different RPC, and handle Klaytn TxTypes. See src/eth/index.ts
    // Try klay_protocolVersion, falls back to eth_protocolVersion
    web3.eth.getProtocolVersion()
    
    // klay_sendTransaction if Klaytn TxType, otherwise eth_sendTransaction
    // Additional treatment for Kaikas compatibility
    web3.eth.sendTransaction(obj)
    
    // klay_sendRawTransaction if Klaytn TxType, otherwise eth_sendRawTransaction
    web3.eth.sendSignedTransaction(rlp)
    
    // klay_signTransaction if Klaytn TxType, otherwise eth_signTransaction
    // Additional treatment for Kaikas compatibility
    web3.eth.signTransaction(obj)

Klaytn RPCs

  • Following functions calls Klaytn RPCs. See src/web3.ts
    web3.klay.blockNumber() // klay_blockNumber
    web3.net.networkID() // net_networkID