To generate the library, run the following command in the root directory of the project:
npx webpack
To generate the documentation, run the following command in the root directory of the project:
npm run generate-docs
The documentation will be generated in the docs/ folder. To view the documentation, open the docs/index.html file in your browser
After you've generated the library, add it to your ethers project with a script tag after you import ethers.js
<script src="https://cdn.ethers.io/lib/ethers-5.2.umd.min.js" type="application/javascript"></script>
<script src="path-to-file/lnr-ethers-0.1.0.js" type="application/javascript"></script>
Setup your ethers environment, and call the LNR constructor and pass it your ethers instance and your signer
const provider = new ethers.providers.Web3Provider(window.ethereum);
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner();
let lnr = new LNR(ethers, signer);
Looks up the address of name. If the name does not have a primary configured, returns null
lnr.resolveName("herpenstein.og");
// 0x00F6426fD5215B0c9A2BFC66D49fA5909FaB7701
Performs a reverse lookup of the address using the primary mapping in the resolver contract. If the address does not have a primary configured, returns null
await lnr.lookupAddress("0x00F6426fD5215B0c9A2BFC66D49fA5909FaB7701");
// herpenstein.og
Callable by the owner or controller, this function configures a primary address so that lnr.lookupAddress resolves to the name specified and lnr.resolveName resolves to the owners address (Note: domain must be unwrapped)
await lnr.setPrimary("herpenstein.og");
Removes the primary address from the user that calls the function
await lnr.unsetPrimary();
Callable by the domain owner, this function delegates a controller address that will be able to use this domain as its primary. (Note: domain must be unwrapped)
await lnr.setController("0x00F6426fD5215B0c9A2BFC66D49fA5909FaB7701");
Callable by the domain owner, this function removes the specified controller from the specified domain
await lnr.unsetController("herpenstein.og", "0x00F6426fD5215B0c9A2BFC66D49fA5909FaB7701");
Checks to see if the address specified is the owner or a controller of the domain
await lnr.verifyIsNameOwner("herpenstein.og", "0x00F6426fD5215B0c9A2BFC66D49fA5909FaB7701");
- Create the wrapper with: lnr.createWrapper(domainName)
- Ensure the users address is returned by: lnr.waitForWrap(domainName)
- Transfer the unwrapped domain with: lnr.transfer(domainName, lnr.wrapperAddress)
- Wrap the domain and get the ERC721 with: lnr.wrap(domainName)
Creates a wrapper for the specified domain
await lnr.createWrapper("herpenstein.og");
Returns the user who wants to wrap the specified domain. Returns null if no wrapper was created (NOTE: Do not transfer domain if waitForWrap returns null!!!)
await lnr.waitForWrap("herpenstein.og");
Called after the wrapper has beed created, checked and the domain has been transfered. This function will issue the user a wrapped ERC721 of their domain
await lnr.wrap("herpenstein.og");
Transfers a wrapped domain
await lnr.safeTransferFrom(fromAddress, toAddress, "herpenstein.og");
Returns [ownerAddress, wrappedStatus] of a specified domain
await lnr.owner("herpenstein.og");
// ["0x00F6426fD5215B0c9A2BFC66D49fA5909FaB7701", "unwrapped"]
Reserves a new domain
await lnr.reserve("herpenstein.og");
Transfers an unwrapped domain to the specified address
await lnr.transfer("0x00F6426fD5215B0c9A2BFC66D49fA5909FaB7701", "herpenstein.og");