viem
Viem is a typescript interface for Ethereum that provides low-level primitives for interacting with Ethereum and other EVM-Compatible blockchain. With kaia supporting features for Ethereum Equivalence, Ethereum tools such as viem can be used on kaia without any significant modifications.
For that reason, developers can leverage this compatibility and use the viem library to interact with a kaia node.
In this guide, you'll learn how to use the viem library to read data from the blockchain, send a transaction, and interact with an existing contract on the kaia Network.
Prerequisites
- Code-Editor: a source-code editor such as VS Code.
- Metamask: used to deploy the contracts, sign transactions and interact with the contracts.
- Điểm cuối RPC: bạn có thể nhận được điều này từ một trong những [Nhà cung cấp điểm cuối] được hỗ trợ (../../public-en.md).
- Test KAIA from Faucet: fund your account with sufficient KAIA.
- NodeJS and NPM
- TS-node: used for running TypeScript scripts.
Setup Project
To get started, you need to create a project directory to house the files to be created in this guide.
mkdir viem-examplecd viem-example
1. Install viem
To install viem run the following command in your terminal:
npm i viem
In this tutorial, we will create a bunch of scripts file to read data from the blockchain, send transactions, and also interact with existing smart contract. To get started, you need to know how to set up viem for each of your script files.