rpc static method
Request rpc
method
rpc method
params
rpc method parameters
Implementation
static Future<dynamic> rpc(String method, List<dynamic> params) async {
final req = RequestBodyEntity();
req.chainId = await ParticleBase.getChainId();
req.jsonrpc = "2.0";
req.id = getCurrentTimestamp();
req.method = method;
req.params = params;
final result = await EvmRpcApi.getClient().rpc(req);
RpcResponse response = RpcResponse.fromJson(jsonDecode(result));
if (response.error != null) {
return Future.error(response.error!);
} else {
return response.result;
}
}