sellAlias method Null safety
- String alias,
- int amount,
- [ResponseCallback<
MsgSellAliasResponse> ? callback]
Listing a Subdomain for Auction
Lists an existing alias
owned by the current account for sale at the given amount
. The minimum price for an Alias is 10.0 SNR. A succesful transaction will return a MsgSellAliasResponse
.
final res = await MotorFlutter.to.sellAlias('hulahoop', 40.0);
if (res == null) {
throw Exception('Failed to sell alias');
}
// Print all domains for sale
for (final alias in res.aliases) {
if(alias.isForSale) {
print(alias.name); // prints: hulahoop.snr or hulahoop
}
}
Next Steps
- Buy an alias listed for sale with transferAlias
- ADR-1
Implementation
Future<MsgSellAliasResponse> sellAlias(String alias, int amount, [ResponseCallback<MsgSellAliasResponse>? callback]) async {
final resp = await MotorFlutterPlatform.instance.sellAlias(MsgSellAlias(
alias: alias,
creator: address.value,
amount: amount,
));
if (resp == null) {
throw UnmarshalException<MsgSellAliasResponse>();
}
domains.addAll(resp.whoIs.alias);
domains.refresh();
callback?.call(resp);
return resp;
}