Skip to content

Instantly share code, notes, and snippets.

@tempe-techie
Last active August 21, 2024 14:24
Show Gist options
  • Save tempe-techie/2e14a9371aa40a286a8442e03ae7c8cf to your computer and use it in GitHub Desktop.
Save tempe-techie/2e14a9371aa40a286a8442e03ae7c8cf to your computer and use it in GitHub Desktop.
.degen names integration

How to integrate .degen names

.degen smart contract: 0x4087fb91A1fBdef05761C02714335D232a2Bf3a1

There are only two functions in the .degen smart contract important for integrations:

  • Resolver: getDomainHolder(name) (note: enter only name without extension, e.g.: tempe, not tempe.degen)
  • Reverse resolver: defaultNames(address)

Resolver (getDomainHolder): get user's address

Try it yourself on block explorer

Useful when you have a name (e.g. tempe.degen) and would like to learn which address is behind this name.

Note: When you enter domain name, enter only the name (e.g. tempe ✅) without extension (not tempe.degen ⛔️).

Example with ether.js:

const degenNameContract = new ethers.Contract(
  "0x4087fb91A1fBdef05761C02714335D232a2Bf3a1", 
  new ethers.utils.Interface(["function getDomainHolder(string calldata _domainName) public view returns(address)"]),
  provider
);

const userAddress = await degenNameContract.getDomainHolder("tempe"); // returns 0xb29050965A5AC70ab487aa47546cdCBc97dAE45D

Reverse resolver (defaultNames): get user's .degen name

Try it yourself on block explorer

Useful when you have an address (e.g. when user connects to your app), and you'd like to get a .degen name of that address.

Example with ether.js:

const degenNameContract = new ethers.Contract(
  "0x4087fb91A1fBdef05761C02714335D232a2Bf3a1", 
  new ethers.utils.Interface(["function defaultNames(address) public view returns(string memory)"]),
  provider
);

const userName = await degenNameContract.defaultNames("0xb29050965A5AC70ab487aa47546cdCBc97dAE45D"); // returns "tempe"

const fullDegenName = username + ".degen"; // tempe.degen

Support

If you'll have any questions regarding the integration, feel free to reach out to Tempe Techie via Farcaster: https://warpcast.com/tempetechie.eth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment