Skip to main content

Space ID

What is Space ID?

Space ID is a name service that allows users to replace the complex contract address with a meaningful and memorable domain.

It's very similar to the DNS from Web2, you may treat Space ID as the DNS, and the contract address is equivalent to the IP address. By using the domain name, it can be resolved to the actual servers' IP address, and the traffic can be redirected accordingly.

How to use Space ID to access a smart contract?

Space ID name resolving service is mainly running on two smart contracts, the "SID Registry" and the "Public Resolver".

Every domain(e.g fr.boracle.bnb) will convert into a node-hash value first, then we use it to query the SID Registry to know which Public Resolver we should visit, finally we can get the contract address we need from the Public Resolver by providing the same node-hash value.

An example is given as follows, let's say we are going to access the Feed Registry Contract with the help of Space ID:

1. Get the node-hash value and use it later
import namehash from 'eth-ens-namehash'

const feedRegistrySID = 'fr.boracle.bnb'
const feedRegistryNodeHash = namehash.hash(feedRegistrySID)


The output should be 0x94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff.

The node-hash value and the address of the SID Registry are remain unchanged.

2. Using in DApp
import "./SIDRegistry.sol";
import "./PublicResolver.sol";

contract MyContract {
// ......

// You may simply copy this function and use it
// replace the nodeHash value with the another one
function getFeedRegistryAddress() internal returns (address memory) {
bytes32 nodeHash = 0x94fe3821e0768eb35012484db4df61890f9a6ca5bfa984ef8ff717e73139faff;

SIDRegistry sidRegistry = SIDRegistry(sidRegistryAddress);
address publicResolverAddress = sidRegistry.resolver(nodeHash);
PublicResolver publicResolver = PublicResolver(publicResolverAddress);

return publicResolver.addr(nodeHash);

// ......


Get SIDRegistry.sol and PublicResolver.sol here which is including in the Binance Oracle Repository.

The SID Registry has different address in the BSC Mainnet and the BSC Testnet.


See the full example

Download the full code and try it out from this GitHub Repo.