iexec / IExecENSModule
module exposing ENS methods
new IExecENSModule(
configOrArgs,options?):IExecENSModule
Create an IExecModule instance
IExecENSModule
config:
IExecConfig
current IExecConfig
claimName(
label,domain?):Promise<{name:string;registerTxHash?:string; }>
register a subdomain (label) on an ENS FIFSRegistrar
NB:
- if specifier, the domain must be controlled by a FIFSRegistrar, default "users.iexec.eth" (use
getDefaultDomain(address)to determine the best suited domain for an address) - if the user already own the domain, the register transaction will not occur
example:
const { name, registerTxHash } = claimName(
'me',
'users.iexec.eth',
);
console.log('registered:', name);
string
string
Promise<{ name: string; registerTxHash?: string; }>
configureResolution(
name,address?):Promise<{address:string;name:string;setAddrTxHash?:string;setNameTxHash?:string;setResolverTxHash?:string; }>
SIGNER REQUIRED, ONLY ENS NAME OWNER
configure the ENS resolution and reverse resolution for an owned ENS name, same as obsConfigureResolution wrapped in a Promise.
NB:
addressmust be an iExec RegistryEntry address (ie: app, dataset or workerpool) or the user address, default user address- the configuration may require up to 3 transactions, depending on the current state, some transaction may or may not occur to complete the configuration
example:
- EOA ENS configuration
const { address, name } = await configureResolution(
'me.users.iexec.eth',
);
console.log('configured resolution:', address, '<=>', name);
- iExec App contract ENS configuration
const { address, name } = await configureResolution(
'my-app.eth',
appAddress
);
console.log('configured resolution:', address, '<=>', name);
string
string
Promise<{ address: string; name: string; setAddrTxHash?: string; setNameTxHash?: string; setResolverTxHash?: string; }>
getDefaultDomain(
address):Promise<string>
get the default free to use ENS domain given an address
NB:
- the ENS domain is determined by the nature of the address (app, dataset, workerpool, other)
- the returned ENS domain is controlled by a FIFSRegistrar that allocates subdomains to the first person to claim them
example:
const domain = await getDefaultDomain(address);
console.log('default domain:', domain);
string
Promise<string>
getOwner(
name):Promise<string|null>
get the address of the ENS name's owner.
example:
const owner = await getOwner('iexec.eth');
console.log('iexec.eth owner:', owner);
string
Promise<string | null>
lookupAddress(
address):Promise<string|null>
lookup to find the ENS name of an ethereum address
example:
const name = await lookupAddress(address);
console.log('ENS name:', name);
string
Promise<string | null>
obsConfigureResolution(
name,address?):Promise<ENSConfigurationObservable>
SIGNER REQUIRED, ONLY ENS NAME OWNER
return a cold Observable with a subscribe method to start and monitor the ENS resolution and reverse resolution configuration.
calling the subscribe method on the observable will immediately return a cancel function and start the asynchronous ENS configuration.
calling the returned cancel method will stop the configuration process
NB:
addressmust be an iExec RegistryEntry address (ie: app, dataset or workerpool) or the user address, default user address- the configuration may require up to 4 transactions, depending on the target type (EOA or RegistryEntry) and the current state, some transaction may or may not occur to complete the configuration
example:
- EOA ENS configuration
const configureResolutionObservable = await obsConfigureResolution(
'me.users.iexec.eth',
);
configureResolutionObservable.subscribe({
error: console.error,
next: ({ message, ...rest }) =>
console.log(`${message} ${JSON.stringify(rest)}`),
completed: () => console.log('resolution configured'),
});
- iExec App contract ENS configuration
const configureResolutionObservable = await obsConfigureResolution(
'my-app.eth',
appAddress
);
configureResolutionObservable.subscribe({
error: console.error,
next: ({ message, ...rest }) =>
console.log(`${message} ${JSON.stringify(rest)}`),
completed: () => console.log('resolution configured'),
});
string
string
Promise<ENSConfigurationObservable>
readTextRecord(
name,key):Promise<string>
read an ENS text record associated to an ENS name
example:
const value = await readTextRecord('me.users.iexec.eth', 'email');
console.log('email record:', value);
string
string
Promise<string>
resolveName(
name):Promise<string|null>
resolve the ENS name to an ethereum address if a resolver is configured for the name
example:
const address = await resolveName('me.users.iexec.eth');
console.log('me.users.iexec.eth:', address);
string
Promise<string | null>
setTextRecord(
name,key,value?):Promise<string>
ONLY ENS NAME OWNER
set a text record associated to an ENS name
NB:
- if value is not specified, the text record is reset to
""
example:
const txHash = setTextRecord(
'me.users.iexec.eth',
'email',
'me@iex.ec'
);
console.log('txHash:', txHash);
string
string
string
Promise<string>
staticfromConfig(config):IExecENSModule
Create an IExecENSModule instance using an IExecConfig instance
IExecENSModule