Update Subnames
After claiming a subname, users can enrich their ENS profile by adding records. The useUpdateSubname hook allows updating text records (avatar, social handles, bio) and coin addresses (multi-chain wallet addresses).
Understanding ENS Records
ENS supports several record types:
Text Records: Key-value pairs for metadata (avatar, description, social links)
Coin Addresses: Wallet addresses for different blockchains
Content Hash: IPFS/IPNS links for decentralized websites
Adding Text Records
Common text record keys include:
avatarβ Profile picture URL (or NFT reference)descriptionβ Bio or about textcom.twitterβ Twitter/X handlecom.githubβ GitHub usernameurlβ Personal website
import { useUpdateSubname } from '@justaname.id/react';
export const UpdateProfile = () => {
const { updateSubname, isPending } = useUpdateSubname();
const handleUpdate = async () => {
await updateSubname({
username: 'myusername',
text: [
{ key: 'avatar', value: 'https://example.com/avatar.png' },
{ key: 'description', value: 'Web3 developer and ENS enthusiast' },
{ key: 'com.twitter', value: 'myhandle' },
{ key: 'com.github', value: 'mygithub' },
{ key: 'url', value: 'https://mywebsite.com' },
]
});
};
return (
<button onClick={handleUpdate} disabled={isPending}>
{isPending ? 'Updating...' : 'Update Profile'}
</button>
);
};Adding Multi-chain Addresses
ENS supports storing addresses for multiple blockchains using coin types defined in SLIP-44 and ENSIP-11. This enables a single ENS name to resolve to different addresses on different chains.
Understanding Coin Types
SLIP-44 coin types: Used for non-EVM chains (Bitcoin = 0, Ethereum = 60, Solana = 501)
ENSIP-11 coin types: Used for EVM-compatible chains, derived from the chain ID
Viem provides a toCoinType helper that converts EVM chain IDs to the correct ENSIP-11 coin type format.
Why
toCoinType? EVM chains share the same address format, so ENSIP-11 defines a formula to derive coin types from chain IDs:coinType = 0x80000000 | chainId. ThetoCoinTypefunction handles this conversion automatically. Learn more about coinType here.
Last updated
Was this helpful?