redeemToken method
Future<Int64>
redeemToken({
- required RedeemableToken token,
- required String accountId,
- required String operator,
- String? contextId,
Credits a redeemable offline token to the specified ledger account. Returns the transaction ID.
Implementation
Future<Int64> redeemToken({
required RedeemableToken token,
required String accountId,
required String operator,
String? contextId,
}) async {
final redeemToken = RedeemToken()
..accountId = hex.decode(accountId)
..token = token;
final client = getServiceClient(operator);
final request = TransactionRequestPayload()
..data = (TransactionData()..redeemToken = redeemToken);
final envelope = await requestEnvelope(
request: request,
contextId: contextId != null ? hex.decode(contextId) : null,
);
final response = await client.tx.createTransaction(envelope);
return response.txId;
}