Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/damartripamungkas/simple-client-eth-rpc
๐ก Simple client rpc for handle eth namespace
https://github.com/damartripamungkas/simple-client-eth-rpc
ethereum ethereum-provider ethersjs json-rpc nodejs provider-package rpc simple-client-eth-rpc web3 web3-dapp web3js
Last synced: 3 months ago
JSON representation
๐ก Simple client rpc for handle eth namespace
- Host: GitHub
- URL: https://github.com/damartripamungkas/simple-client-eth-rpc
- Owner: damartripamungkas
- License: mit
- Created: 2023-04-19T02:02:09.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-19T11:38:45.000Z (6 months ago)
- Last Synced: 2024-11-07T04:20:35.330Z (3 months ago)
- Topics: ethereum, ethereum-provider, ethersjs, json-rpc, nodejs, provider-package, rpc, simple-client-eth-rpc, web3, web3-dapp, web3js
- Language: TypeScript
- Homepage: https://npmjs.com/package/simple-client-eth-rpc
- Size: 162 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
SIMPLE-CLIENT-ETH-RPC
### ๐ Description :
This very light package was created for those of you who want to interact directly with the EVM Ethereum blockchain according to the documentation.
- support network http
- support network websocket
- support network ipc### ๐ป Step to install :
```
npm install --production simple-client-eth-rpc
```### โ๏ธ Example :
#### Typescript
```javascript
import { Provider } from "simple-client-eth-rpc";
const provider = new Provider("https://bscrpc.com");
```#### ESM (import)
```javascript
import { Provider } from "simple-client-eth-rpc";
const provider = new Provider("https://bscrpc.com");
```#### CommonJs (require)
```javascript
const { Provider } = require("simple-client-eth-rpc");
const provider = new Provider("https://bscrpc.com");
```#### Usage
```javascript
const { Provider } = require("..");/**
* @args_1 url rpc http/ws/ipc
* @args_2 socket optional for ws/ipc
* @args_3 reconnect optional for ws/ipc
* @args_4 override formatReturn eth method
* @returns object
*/
const provider = new Provider("https://bscrpc.com", null, null, [
{ method: "eth_chainId", formatReturn: BigInt },
{ method: "eth_blockNumber", formatReturn: BigInt },
]);(async () => {
/**
* @info [require] first run function isReady before send request
* @returns bool
*/
await provider.isReady();/**
* @test test 1 request
* @info run eth_chainId
* @returns BigInt
*/
const getChainId = await provider.ethSend.eth_chainId();
console.log(`INFO: result eth_chainId:`, getChainId);/**
* @test test multi request
* @info run eth_chainId, eth_blockNumber
* @returns Array[BigInt, BigInt]
*/
const getBlockNumberAndChainId = await provider.sendBatch(
provider.ethBuild.eth_chainId(),
provider.ethBuild.eth_blockNumber()
);
console.log(
`INFO: result eth_chainId, eth_blockNumber:`,
getBlockNumberAndChainId
);/**
* @test custom send eth
* @info get gasPriceLevel in spesific block
* @returns Object{ all, top, mid, bottom }
*/
const getGasPriceLevel = await provider.customSend.getGasPriceLevel();
console.log(`INFO: result gasprice level top: ${getGasPriceLevel.top}`);
})();
```full example see [here](./test)
### ๐งพ Pre-Requisistes :
```
node.js >= 18
```### ๐ License :
Licensed under the [MIT License](./LICENSE).