get Primary Name
Retrieves the primary name for an account, if one is set.
An account can have multiple names that point to it, but only one can be its primary name.
Usage
val aptos = Aptos(AptosConfig(AptosSettings(network = Network.MAINNET)))
val address =
AccountAddress.fromString("0xc675...e9e")
val resolution = aptos.getPrimaryName(address)
when (resolution) {
is Result.Ok -> {
val primaryName = resolution.value
// Expected output: "greg"
println("The primary name for the address is: $primaryName")
}
is Result.Err -> {
println("Error retrieving primary name: ${resolution.error.message}")
}
}Content copied to clipboard
Return
A Result which is either Result.Ok containing the primary name String, or Result.Err containing an AptosSdkError.
Parameters
address
The account address to query.