Note: use this lib as reference but preferred way is to re-write package from zero instead of refactoring this one. When you don't need this anymore, you can delete it
Sample library that exposes a Blockchain provider to query account balances on Ethereum mainnet or EVM-compatible blockchains
- Change package name to your own in
package.json
- Install dependencies running
pnpm install
Available scripts that can be run using pnpm
:
Script | Description |
---|---|
build |
Build library using tsc |
check-types |
Check types issues using tsc |
clean |
Remove dist folder |
lint |
Run ESLint to check for coding standards |
lint:fix |
Run linter and automatically fix code formatting issues |
format |
Check code formatting and style using Prettier |
format:fix |
Run formatter and automatically fix issues |
test |
Run tests using vitest |
test:cov |
Run tests with coverage report |
You can import the package in your TypeScript or JavaScript files as follows:
import { BlockchainProvider } from "@ts-turborepo-boilerplate/sample-lib";
// EVM-provider
const rpcUrl = ""; //non-empty valid url
const address = "0x...";
const provider = new BlockchainProvider(rpcUrl);
const balance = await provider.getBalance(address);
console.log(`Balance of ${address} is ${balance}`);
Available methods
getBalance(address: Address)