Interacting with Rootstock using Viem
Viem offers a minimalist, lightweight, and more efficient Typescript interface alternative to Ethers.js and Web3.js for interacting with Ethereum nodes. It maintains a bundle size of 35KB compared to Ethers and Web3.js, which are over 300KB and 600KB, respectively. Smaller bundle size implies faster page loads and better performance on mobile. Viem also offers more granular control over APIs in contrast to Ethers.js, which abstracts APIs for more functionalities.
This tutorial will teach you how to use Viem to interact with your contracts on Rootstock.
Installation and Setup
In this guide, you will learn how to interact with an existing lending contract on the Rootstock Explorer, rLending RBTC. The full code of the working demo is available on GitHub.
You can use the following command to install the Viem npm package:
npm install viem
For more installation options, you can check out the official installation guide.