Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/idecentralize-finance/erclib
An ERC Library for Ethereum and other EVM compatible chains.
https://github.com/idecentralize-finance/erclib
blockchain cryptocurrency dapp ethereum library web3
Last synced: 2 months ago
JSON representation
An ERC Library for Ethereum and other EVM compatible chains.
- Host: GitHub
- URL: https://github.com/idecentralize-finance/erclib
- Owner: idecentralize-finance
- License: mit
- Created: 2021-12-05T01:26:04.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-12T15:50:43.000Z (over 1 year ago)
- Last Synced: 2024-11-01T01:15:34.295Z (3 months ago)
- Topics: blockchain, cryptocurrency, dapp, ethereum, library, web3
- Language: JavaScript
- Homepage:
- Size: 153 KB
- Stars: 3
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# erclib
[![Version npm](https://img.shields.io/npm/v/@idecentralize/erclib.svg?logo=npm)](https://www.npmjs.com/package/@idecentralize/erclib)
[![Node.js CI](https://github.com/idecentralize-finance/erclib/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/idecentralize-finance/erclib/actions/workflows/npm-publish.yml)
[![Socket Badge](https://socket.dev/api/badge/npm/package/@idecentralize/erclib)](https://socket.dev/npm/package/@idecentralize/erclib)ERC library for blockchain Development
In development. More networks, asset's and features are coming...
## Install and import
```npm install @idecentralize/erclib```
> *address should be checksumed*
## Usage
### Retrieve the chain id from your current provider or configuration
```javascript
// using ethersV6
import {BrowserProvider} from "ethers";
const provider = new BrowserProvider(window.ethereum);
const chainId = (await PROVIDER.getNetwork()).chainId.toString()
```### import your library
- ERC20
- ERC721
- NETWORK
- ROUTER
- IPFS_SVG_PATHExample of the NETWORK object entry
```javascript
id: 137,
network: "Polygon",
chain: "MATIC",
chainId: 137,
type: "Mainnet",
rpc:"https://polygon-rpc.com",
explorer: "https://polygonscan.com/address/",
color: "#8247e5",
defaultNFT: "0x5265535c7
```Show the chain native currency logo
```javascript
import {IPFS_SVG_PATH, NETWORK} from "@idecentralize/erclib";
``````javascript
const rpc = NETWORK[chainId].rpc
const usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const decimals = ERC20[chainId][usdc].decimals
const CToken = ERC20[chainId][usdc].compound
const color = ERC20[chainId][usdc].colors
```> FORKING :
> network_id should be the chain id return by the provider.
> When forking the mainnet using hardhat, the network id is 31337 and we want to use the mainnet asset under network id 1.```javascript
ERC20[network_id === 31337 ? 1 : network_id][usdc].decimals // output decimals of asset
```# Supported Network
- IPFS
- Ethereum
- Polygon
- BSC
- Aurora
- Avanlance
- xDai# Supported Testnet & protocols
- Compound
- Aave
- Yearn v2Please report any issues!
To add some assets, please submit a PR and provide the new IPFS CID.