approval.getToken
Reads the address approved to transfer one ENSv1 name token (getApproved). Parameters, return value, errors and examples for approval.getToken in @ensforge/sdk.
Reads the address approved to transfer one ENSv1 name token (getApproved).
When to use
Use to check a pending single-name approval, e.g. before listing a name for sale.
Details
- Wrapped names use the NameWrapper token; unwrapped
.ethnames the BaseRegistrar token. - ENSv2 names have no single-token approval; use operators.
Signature
function getToken(client: Like, options: getToken.Options): Promise<getToken.ReturnType>Call it as ens.approval.getToken(options) on a client, or Actions.approval.getToken(client, options).
approval.getToken.request(options) builds a deferred read for Actions.batch. See Look up many at once.
Parameters
| Option | Type | Default | Description |
|---|---|---|---|
name (required) | string | ENS name. Normalized automatically. |
Also takes the read options.
Returns
Resolves to Address | null. The approved address, or null.
Errors
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME | the name cannot be normalized. |
UnsupportedError | UNSUPPORTED_PROTOCOL | ENSv2 names and unwrapped subnames. |
NetworkError | RPC_REQUEST_FAILED, RPC_TIMEOUT, RATE_LIMITED | the RPC request fails. |
It can also fail with the errors every read can (Errors.CommonError: ConfigError, ContractRevertError, InternalError, NetworkError).
See How errors work.
Examples
const approved = await ens.approval.getToken({ name: "alice.eth" })See also
approval.setTokento change it
Was this page helpful?