Skip to content

Instantly share code, notes, and snippets.

@5ajaki
Forked from sbauch/ens-formula.js
Last active December 15, 2024 18:03
Show Gist options
  • Save 5ajaki/1d2877a41e1d021baa3e7c828b0e7226 to your computer and use it in GitHub Desktop.
Save 5ajaki/1d2877a41e1d021baa3e7c828b0e7226 to your computer and use it in GitHub Desktop.
ENS names in Google Sheets
// Easily resolve addresses in a Google sheet to ENS names via @frolic's ENS resolution API - https://ensideas.com/about
// 1. In a Google sheet, select the menu item Extensions > Apps Script.
// 2. Replace the example code in the editor with the below function:
function LOOKUP_ENS(input) {
var endpoint = "https://api.ensideas.com/ens/resolve/" + input;
var response = UrlFetchApp.fetch(endpoint);
var json = response.getContentText();
var data = JSON.parse(json);
return data.displayName;
}
function LOOKUP_ENS_ADDRESS(input) {
if (!input) return "";
var endpoint = "https://api.ensideas.com/ens/resolve/" + input;
var response = UrlFetchApp.fetch(endpoint);
var json = response.getContentText();
var data = JSON.parse(json);
return data.address;
}
// 3. Click the disk icon to save
// 4. click "Run" to check permissions
/* 5. Return to the sheet you want to use the formula. In a field, add the formula
=LOOKUP_ENS(address) for reverse resolution
OR
=LOOKUP_ENS_ADDRESS(name) for forward resolution
You probably want to reference another field that contains an address, like
=LOOKUP_ENS(A1)
The cell will display an ENS name if one is configured for the address, otherwise the truncated address is displayed.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment