Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyscott18/reverse-mirage
Application level TypeScript utilities for Ethereum
https://github.com/kyscott18/reverse-mirage
Last synced: about 1 month ago
JSON representation
Application level TypeScript utilities for Ethereum
- Host: GitHub
- URL: https://github.com/kyscott18/reverse-mirage
- Owner: kyscott18
- License: mit
- Created: 2023-07-11T20:44:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-18T01:47:31.000Z (10 months ago)
- Last Synced: 2024-11-29T05:21:03.736Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://reversemirage.com
- Size: 31.4 MB
- Stars: 49
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Reverse Mirage [![GitHub Actions][gha-badge]][gha] [![npm version][npm-badge]][npm]
[gha]: https://github.com/kyscott18/reverse-mirage/actions
[gha-badge]: https://github.com/kyscott18/reverse-mirage/actions/workflows/main.yml/badge.svg
[npm]: https://www.npmjs.com/package/reverse-mirage/v/latest
[npm-badge]: https://img.shields.io/npm/v/reverse-mirage/latest.svgBuilding blocks for Ethereum app development. Built using [Viem](https://viem.sh).
## Features
- ✅ 10x-100x faster, 11.6x smaller than [`@uniswap/sdk-core`](https://github.com/uniswap/sdk-core)
- ✅ Abstactions for most commonly used token standards
- ✅ Supports `permit`
- ✅ Extensible to build apps and libraries
- ✅ Seamless extension to [Viem](https://github.com/wagmi-dev/viem)
- ✅ TypeScript ready
- ✅ Test suite running against local Ethereum network## Example
```ts
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { publicActionReverseMirage, amountToNumber } from 'reverse-mirage'export const publicClient = createPublicClient({
chain: mainnet,
transport: http()
}).extend(publicActionsReverseMirage)// read token metadata
const usdc = await publicClient.getERC20({
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc
id: mainnet.id
})console.log(usdc.decimals) // 6
console.log(usdc.name) // USD Coin// read a balance
const vitalikBalance = await publicClient.getERC20Balance({
erc20: usdc,
address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' // vitalik
})console.log(vitalikBalance.amount) // 420690000n
console.log(amountToNumber(vitalikBalance)) // 420.69
```## Installation
```sh
$ npm i reverse-mirage
```## Benchmarks
Benchmarks are done with [mitata](https://github.com/evanwashere/mitata). To reproduce:
```sh
$ cd packages/core/
$ bun run src/amount/utils.bench.ts
```### Results
- amount add: `reverse mirage` **8.31x** faster than `@uniswap/sdk-core`
- amount equal to: `reverse-mirage` **18.9x** faster than `@uniswap/sdk-core`
- amount to number: `reverse-mirage` **313x** faster than `@uniswap/sdk-core`
- amount to significant: `reverse-mirage` **27.1x** faster than `@uniswap/sdk-core`## Bundle Size
`reverse-mirage`: **4.61 kB**
`@uniswap/sdk-core`: **53.4 kB**