rpc static method

Future rpc(
  1. String method,
  2. List params
)

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 SolanaRpcApi.getClient().rpc(req);
  RpcResponse response = RpcResponse.fromJson(jsonDecode(result));
  if (response.error != null) {
    return Future.error(response.error!);
  } else {
    return response.result;
  }
}