getTokenAccountsByOwner method
get TokenAccounts By Owner with mint
or token program
Implementation
Future<RPCResponse<TokenAccountsByOwner>> getTokenAccountsByOwner(
{String? mint}) async {
final body = json.encode({
"jsonrpc": "2.0",
"id": 1,
"method": RPCMethod.getTokenAccountsByOwner,
"params": [
address,
mint != null ? {'mint: $mint'} : {"programId": Token.TOKEN_PROGRAM_ID},
{"encoding": "jsonParsed"}
]
});
final response = await _httpClient.post(_url, data: body);
return RPCResponse<TokenAccountsByOwner>.fromJson(response.data,
onData: (Map<String, dynamic> value) {
return TokenAccountsByOwner.fromJson(value);
});
}