Skip to content

Instantly share code, notes, and snippets.

@mdtanrikulu
Created September 7, 2024 13:13
Show Gist options
  • Save mdtanrikulu/96efbec999a4bc611d1cbd783a563e7d to your computer and use it in GitHub Desktop.
Save mdtanrikulu/96efbec999a4bc611d1cbd783a563e7d to your computer and use it in GitHub Desktop.
minimal raw html, viem ens starter
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>blah</title>
</head>
<body>
<p>I'm the content</p>
</body>
<script type="module">
import {
createPublicClient,
http,
} from 'https://cdn.jsdelivr.net/npm/[email protected]/+esm';
import { mainnet } from 'https://cdn.jsdelivr.net/npm/[email protected]/chains/+esm';
import { normalize } from 'https://cdn.jsdelivr.net/npm/[email protected]/ens/+esm';
const client = createPublicClient({
chain: mainnet,
transport: http(
'https://eth.llamarpc.com'
),
});
const ensName = normalize('tanrikulu.eth');
try {
const address = await client.getEnsAddress({
name: ensName,
});
const fetchedEnsName = await client.getEnsName({
address,
})
const description = await client.getEnsText({
name: ensName,
key: 'description',
});
const avatar = await client.getEnsText({
name: ensName,
key: 'avatar',
});
console.log('ens name', fetchedEnsName);
console.log('address', address);
console.log('description', description);
console.log('avatar', avatar);
} catch (error) {
console.log(error);
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment