whoisens-lib
Version:
Whois for ENS (Ethereum Name Service) lookup service
35 lines • 1.06 kB
JavaScript
import JSON_RPC from 'json-rpc3/dist/esm/index.js';
import Config from '../lib/Config.js';
export default class JSONRPCRequest {
constructor() {
this.jsonRPC = new JSON_RPC({
url: Config.getInstance().currentNetworkURL
});
}
static getInstance() {
if (!JSONRPCRequest.instance)
JSONRPCRequest.instance = new JSONRPCRequest();
return JSONRPCRequest.instance;
}
/**
* Make a JSON-RCP call
* @link https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call
* @link https://solidity.readthedocs.io/en/latest/abi-spec.html#examples
*/
async makeRequest({ to, data }) {
return (await this.jsonRPC.calls({
method: 'eth_call',
params: [{
to,
data
}, 'latest']
})).get();
}
async getNetworkID() {
return (await this.jsonRPC.calls({
method: 'net_version',
params: []
})).get().result;
}
}
//# sourceMappingURL=json-rpc.js.map