3.1.1 โข Published 2 years ago
simple-client-eth-rpc v3.1.1
๐ 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
import { Provider } from "simple-client-eth-rpc";
const provider = new Provider("https://bscrpc.com");
ESM (import)
import { Provider } from "simple-client-eth-rpc";
const provider = new Provider("https://bscrpc.com");
CommonJs (require)
const { Provider } = require("simple-client-eth-rpc");
const provider = new Provider("https://bscrpc.com");
Usage
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
๐งพ Pre-Requisistes :
node.js >= 18
๐ License :
Licensed under the MIT License.
3.1.1
2 years ago
2.4.1
2 years ago
2.4.0
2 years ago
3.1.0
2 years ago
3.0.0
2 years ago
2.2.9
2 years ago
2.3.0
2 years ago
2.3.2
2 years ago
2.0.5
2 years ago
2.0.4
2 years ago
2.0.7
2 years ago
2.2.7
2 years ago
2.1.0
2 years ago
2.0.0
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago