Managing names
Call Batching
You will often need to make several RPC calls to get the information you need. id.js uses on-chain resolvers to make resolving records faster. It also coalesces lookups into a single eth_call
when possible. This process is done seamlessly. To take advantage of it, batch your calls using Promise.all
or Promise.allSettled
. Requests made within a few ms will create a single in-flight eth_call
. You can even combine your own API calls and await all of them!
import { Id } from '@imperviousinc/id';
import { BrowserProvider, Contract, parseEther } from 'ethers';
const provider = new BrowserProvider(...); // get a provider
const network = await provider.getNetwork() ;
const id = new Id({network, provider});
// Single in-flight call
const results = await Promise.all([
id.getPrice('mycoolname.eth', 365*24*60*60),
id.getOwner('vitalik.eth'),
id.getAddress('live.forever'),
id.getDns('impervious.forever', {name:'_443._tcp.impervious.forever', type: 'TLSA'}),
id.getRegistration('vitalik.eth'),
id.getText('vitalik.eth', 'url')
]);
To learn more about Promise.all, Promise.allSettled see MDN docs