This page uses machine translation from English, which may contain errors or unclear language. For the most accurate information, please see the original English version. Some content may be in the original English due to frequent updates. Help us improve this page's translation by joining our effort on Crowdin. (Crowdin translation page, Contributing guide)
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-kairos.node.kaia.io");
- CommonJS
const { Web3 } = require("@kaiachain/web3js-ext");const web3 = new Web3("https://public-en-kairos.node.kaia.io");
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
Modifications to the Web3 object
See DESIGN for source code organization.