getTransactionInfo method

Future<NearTransactionInfoModel> getTransactionInfo(
  1. String accountId,
  2. String publicKey
)

Implementation

Future<NearTransactionInfoModel> getTransactionInfo(
  String accountId,
  String publicKey,
) async {
  Uint8List hash = HEX.decode(publicKey) as Uint8List;

  final res = await networkClient.postHTTP('', {
    "jsonrpc": "2.0",
    "id": "dontcare",
    "method": "query",
    "params": {
      "request_type": "view_access_key",
      "finality": "final",
      "account_id": accountId,
      "public_key": "ed25519:${base58.encode(hash)}"
    }
  });
  if (res.isSuccess) {
    final nonce = int.tryParse(res.data['result']['nonce'].toString()) ?? 0;
    final blockHash = res.data['result']['block_hash'].toString();
    return NearTransactionInfoModel(blockHash: blockHash, nonce: nonce);
  } else {
    return NearTransactionInfoModel(blockHash: '', nonce: 0);
  }
}