How to resolve a .sol domain cross-chain?

The Solana Name Service (SNS) going cross-chain means that it is expanding its functionality beyond the Solana ecosystem, enabling users to export their domain names to alternative blockchains using the Wormhole bridge. This move aims to increase the utility and adoption of SNS, while also fostering collaboration and interoperability between different blockchain networks. By allowing SNS domains to be resolved on supported chains like EVM-based chains and Injective, SNS becomes more accessible to a wider range of developers and users, promoting the growth of the Solana ecosystem and showcasing its capabilities beyond its native environment.

EVM Chains

The Solana Name Service has been bridged to the following EVM chains:

  • BNB Testnet (deployed at 0x4d50e149bb3d8c889f4ccdfffba0ef8016168d92)
  • BNB Mainnet (deployed at 0xd1Ae42Ce34E6b7ab5B41dcc851424F3cF410BF16)

Solana domain names bridged on EVM chains can be resolved using the NPM package @bonfida/sns-warp-evm.

Installation

With Yarn:

yarn add @bonfida/sns-warp-evm

With NPM

npm i @bonfida/sns-warp-evm

Resolving a .sol domain

The following code can be used to resolve .sol domains on EVM chains

import { SupportedChains, SNS } from "@bonfida/sns-warp-evm";

// The domain name to resolve
const domain = "mock3.sol";
// The chain on which to resolve the domain
const targetChain = SupportedChains.BNBMainnet;

const sns = new SNS(SupportedChains.BNBMainnet);
const resolved = await sns.resolveName(domain);

console.log(resolved); // <- 0x1D719d2dB763f905b1924F46a5185e001Dd93786

Reverse look up

import { SupportedChains, SNS } from "@bonfida/sns-warp-evm";
import { namehash } from "@ethersproject/hash";

// The chain on which to perform the reverse lookup
const targetChain = SupportedChains.BNBMainnet;

const sns = new SNS(targetChain);
const nameHash = namehash("mock3.sol");

const resolved = await sns.resolveReverse(nameHash);
console.log(resolved); // <- mock3

Injective

The Solana Name Service has also been bridged to Injective.

  • Injective Testnet (deployed at inj1q79ujqyh72p43mhr2ldaly3x6d50rzp3354at3)
  • Injective Mainnet (deployed at inj1v7chmgm7vmuwldjt80utmw9c95jkrch979ps8z)

Solana domain names bridged to Injective can be resolved using the NPM package @bonfida/sns-warp-injective.

SNS is also supported by the Leap Wallet Name Match package.

Installation

With Yarn:

yarn add @bonfida/sns-warp-injective

With NPM

npm i @bonfida/sns-warp-injective

Resolving a .sol domain

The following code can be used to resolve .sol domains on Injective

import { resolveName } from "@bonfida/sns-warp-injective";
import { Network } from "@injectivelabs/networks";

// The domain name to resolve
const domain = "bonfida.sol";
// The network on which to resolve the domain
const network = Network.Mainnet;

const resolved = await resolveName(domain, network);

console.log(resolved); // <- inj1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqe2hm49