permission.setRecordAccess
Lets another account edit a name's records, or takes that access back. Options, result, errors and examples for permission.setRecordAccess.
Lets another account edit a name's records, or takes that access back. Resolves once the transaction is submitted.
When to use
Use to let a teammate, bot or app manage some or all of a profile. Use setRecordAccessSync to wait for the receipt.
Details
- PermissionedResolver: exact setter roles per record (one text key, coin, data key, ABI
content type or interface), or every setter role with
records: "all". - Public resolvers: a per-name delegate, which can edit every record of the name.
revoketakes the same access back.
Gotchas
- PermissionedResolver roles cover every name on that resolver. Names share a resolver
with
resolver: "parent"; give names their own resolver to keep access per name. - Delegates and
"all"needallowScopeWidening: true.
Signature
function setRecordAccess(
client: Like,
options: setRecordAccess.Options & Write.Options,
): Promise<setRecordAccess.ReturnType>Call it as ens.permission.setRecordAccess(options) on a client, or Actions.permission.setRecordAccess(client, options).
Parameters
| Option | Type | Default | Description |
|---|---|---|---|
name (required) | string | ENS name. Normalized automatically. | |
grantee (required) | string | Account that gets (or loses) access. | |
records | Selection | "all" | "all" | Records in the record.get selection shape, or "all". |
allowScopeWidening | boolean | Confirm grants wider than the listed records (delegates, "all"). | |
revoke | boolean | Take the access back. |
Also takes the write options.
Returns
Resolves to Write.Result. Submitted transaction hashes and the plan that produced them.
| Field | Type | Description |
|---|---|---|
hash | Hex | Hash of the last transaction. |
hashes | readonly Hex[] | Every submitted transaction, in order. |
id | string | EIP-5792 bundle id when the calls were sent as one batch. |
plan | Plan | The plan the write executed: its steps, in order, as they were submitted. |
Errors
| Error | Codes | When |
|---|---|---|
InvalidInputError | INVALID_NAME, INVALID_ADDRESS, INVALID_RECORD_VALUE | invalid input or an unconfirmed widening. |
NotFoundError | RESOLVER_NOT_FOUND | the name has no resolver. |
UnsupportedError | RESOLVER_PROFILE_UNSUPPORTED | public keys on a PermissionedResolver. |
UnauthorizedError | CANNOT_GRANT_ROLES, NOT_OWNER | the account may not grant access. |
UserRejectedError | USER_REJECTED | the user rejects the request. |
WalletError | CHAIN_MISMATCH, ACCOUNT_NOT_FOUND | the wallet is on another chain or has no account to sign with. |
UnsupportedError | WALLET_BATCH_UNSUPPORTED | with mode: "batch" or a paymaster when the wallet cannot send calls as one batch. |
It can also fail with the errors every write can (Errors.WriteError: the common errors plus InsufficientFundsError, TransactionError, UnsupportedError, UserRejectedError, WalletError).
See How errors work.
Examples
const { hash } = await ens.permission.setRecordAccess({ name: "alice.eth", grantee: "0xB0b0000000000000000000000000000000000000", records: { texts: ["url"] } })Plan methods
Each method takes the same options as permission.setRecordAccess and sends nothing. See Preview before sending.
| Method | Description |
|---|---|
permission.setRecordAccess.prepare(options) | Builds the plan without sending anything. |
permission.setRecordAccess.simulate(options) | Simulates the plan with eth_call, reporting each step. |
permission.setRecordAccess.estimateGas(options) | Estimates the gas and ETH the plan needs. |
Wait for the receipt with setRecordAccessSync
Lets another account edit a name's records, or takes that access back. Resolves once the receipt is in.
Use when the next step depends on the change being on-chain.
permission.setRecordAccessSync takes the same options plus confirmations and timeout.
Resolves to Write.SyncResult. Receipts plus the submitted hashes and plan.
const { receipt } = await ens.permission.setRecordAccessSync({ name: "alice.eth", grantee: "0xB0b0000000000000000000000000000000000000", records: { texts: ["url"] } })See also
permission.getto read access
Was this page helpful?