The all-in-one DID SDK, resolving all decentralized name(Web3 Name).
This is a whole new version of denames. If you are looking for the source code of npm package denames(Deprecated), please check out the branch denames.
- Check if the given name is a valid DID name.(e.g. isSupported, isRegistered, isAvailable.)
- Query DID name info (e.g. owner, manager.)
- Query DID name records (e.g. tokenId, records, addresses, dwebs, reverse and registryAddress.)
- Supported decentralized name suffix:
- Ethereum Name Service - ENS
- .eth
- .bit - DOTBIT
- .bit
- Solana Name Service - SNS
- .sol
- Unstoppable Domains Name Service - UNS. Please, refer to the Top Level Domains List.
- .crypto
- .bitcoin
- .blockchain
- .dao
- .nft
- .888
- .wallet
- .x
- .klever
- .zil
- .hi
- Space ID - SID
- .bnb
- Starknet.id (TBD)
- .stark
- Lens Protocal (TBD)
- .lens
- Ethereum Name Service - ENS
First, you need to install alldid
using npm
npm install alldid --save
or yarn
.
yarn add alldid
Then, you need to import AllDID.js SDK in your code and create an instance before interacting with it:
// For CommonJS
const { createInstance } = require('alldid')
const alldid = createInstance()
// For ES Module
import { createInstance } from 'alldid'
const alldid = createInstance()
Now you could perform various operations using AllDID.js SDK. Here is a simple example:
// Get DID name address
alldid.addrs('leonx.bit', ['eth']).then(console.log)
alldid.addrs('leon.wallet', ['eth']).then(console.log)
alldid.addrs('π.sol', ['eth']).then(console.log)
A sample result would be like:
// leonx.bit
[
{
"key": "address.eth",
"label": "",
"subtype": "eth",
"symbol":"ETH",
"ttl": 300,
"type": "address",
"value": "0xC72B6f66017246d6A7f159F5C2BF358188AD9ECa"
}
]
// leon.wallet
[
{
"key": "address.eth",
"label": "",
"subtype": "eth",
"symbol":"ETH",
"ttl": 0,
"type": "address",
"value": "0x98e32b218bd1d8f3c267466b8d7635501dbdd1c1"
}
]
// π.sol
[
{
"key": "address.eth",
"label": "",
"subtype": "eth",
"symbol":"ETH",
"ttl": 0,
"type": "address",
"value": "0x570eDC13f9D406a2b4E6477Ddf75D5E9cCF51cd6"
}
]
TBD
- installService(service)
- isSupported(name)
- isRegistered(name)
- isAvailable(name)
- owner(name)
- manager(name)
- tokenId(name)
- records(name, keys?)
- addrs(name, currencyTicker?)
- dwebs(name)(todo)
- reverse(address)(todo)
- registryAddress(name)
Used to install a NamingService and add it to the services array.
Note: For a better development experience, we suggest you using createInstance to initialize AllDID, since it has already set a bunch of default services.
service: NamingService
NamingService is a concrete implementation compatible with a specific Domain Name System.
N/A
const { AllDID } = require('alldid');
// To create a new AllDID instance.
const alldid = new AllDID()
alldid.installService(new DotbitService(defaultCreateInstanceOptions.dotbit))
Used to check if a DID name is supported by install's NamingService. Returns true if any NamingService supports the DID name, false otherwise.
name: string
boolean
// Check if the given name is a valid DID name.
alldid.isSupported('abc.bit').then(console.log)
// The printed result would be like:
true
It is used to query whether the DID name has been registered, if it has been registered, it returns true, otherwise it returns false.
name: string
boolean
// Check if the given name is registered
alldid.isRegistered('jeffx.bit').then(console.log)
// The printed result would be like:
true
Used to query whether the DID name is available, return true if available, otherwise return false.
name: string
boolean
// Check if it is available to register
alldid.isAvailable('jeffx.bit').then(console.log)
// The printed result would be like:
true
The address used to query the owner of the DID name, the format of the address varies according to different domain name systems.
name: string
address string
// Query the address of the owner of the name
alldid.owner('leon.bit').then(console.log)
alldid.owner('leon.sol').then(console.log)
// The printed result would be like:
// leon.bit
"0x0403d6d288db8908b5ff21b60d347c6e450eb828"
// leon.sol
"FvfD9ziv4CuPj5BSD278jy6sX8Q2GTZeQZNfQ89eE4P9"
Query the address of the manager of the DID name. The address format is different according to different domain name systems.
Note: If this method is not supported, an "Unsupported Method" exception will be thrown
name: string
address string
// Query the address of the manager of the name
alldid.manager('leon.bit').then(console.log)
alldid.manager('leon.eth').then(console.log)
// The printed result would be like:
// leon.bit
"0x0403d6d288db8908b5ff21b60d347c6e450eb828"
// leon.eth
"0xfA45C6991a2C3d74ada3A279E21135133CE3Da8A"
Query the TokenID of the DID name.
The TokenID format is different according to different domain name systems.
name: string
hex string
// Query the tokenId of the name
alldid.tokenId('leon.bit').then(console.log)
alldid.tokenId('leon.sol').then(console.log)
// The printed result would be like:
// leon.bit
"0x38ae79fc97c608c6a9707d5df4bf44d1a4d8d6ab"
// leon.sol
"3iV8KnUZkM78tUAwWb9V9c7FWaFxCrqpC3tFzywrEayg"
Query all records of DID name, return an array.
name: string keys?: string | string[]
keys are string or string[] type, a set of labels separated by .
support the following formats:
enum KeyPrefix {
Address= 'address',
Profile= 'profile',
Dweb = 'dweb',
Text = 'text'
}
// eth adress
'address.eth'
// uns dweb
'dweb.ipfs.hash'
// uns profile
'profile.social'
RecordItem[]
// Query the records of the name
alldid.records('leon.bit', 'address.eth').then(console.log)
alldid.records('leont.eth', ['address.eth']).then(console.log)
alldid.records('Brad.crypto').then(console.log)
// The printed result would be like:
// leon.bit
[
{
"key": "address.eth",
"label": "",
"subtype": "eth",
"ttl": 300,
"type": "address",
"value": "0xC72B6f66017246d6A7f159F5C2BF358188AD9ECa"
}
]
// leon.eth
[
{
"key": "address.eth",
"label": "",
"subtype": "eth",
"ttl": 0,
"type": "address",
"value": "0xC72B6f66017246d6A7f159F5C2BF358188AD9ECa"
}
]
// Brad.crypto
[
{
key: "address.btc",
label: "",
subtype: "btc",
ttl: 0,
type: "address",
value: "bc1q359khn0phg58xgezyqsuuaha28zkwx047c0c3y"
},
{
key: "profile.picture",
label: "",
subtype: "picture",
ttl: 0,
type: "profile",
value: "1/erc1155:0xc7e5e9434f4a71e6db978bd65b4d61d3593e5f27/14317"
},
{
key: "profile.username",
label: "",
subtype: "username",
ttl: 0,
type: "profile",
value: "0x8912623832e174f2eb1f59cc3b587444d619376ad5bf10070e937e0dc22b9ffb2e3ae059e6ebf729f87746b2f71e5d88ec99c1fb3c7c49b8617e2520d474c48e1c"
},
{
key: "dweb.html_value",
label: "",
subtype: "html_value",
ttl: 0,
type: "dweb",
value: "QmTiqc12wo2pBsGa9XsbpavkhrjFiyuSWsKyffvZqVGtut"
}
]
Query the addresses of DID name.
name: string currencyTicker?: string | string[]
RecordItemAddr[]
// Query the addresses of the name
alldid.addrs('leonx.bit', ['eth']).then(console.log)
alldid.addrs('Brad.crypto', ['eth', 'btc']).then(console.log)
// The printed result would be like:
// leonx.bit
[{
"key": "address.eth",
"label": "",
"subtype": "eth",
"ttl": 300,
"type": "address",
"symbol": "ETH",
"value": "0xC72B6f66017246d6A7f159F5C2BF358188AD9ECa"
}]
// Brad.crypto
[
{
key: "address.eth",
label: "",
subtype: "eth",
ttl: 0,
type: "address",
value: "0x8aaD44321A86b170879d7A244c1e8d360c99DdA8",
symbol: 'ETH'
},
{
key: "address.btc",
label: "",
subtype: "btc",
ttl: 0,
type: "address",
value: "bc1q359khn0phg58xgezyqsuuaha28zkwx047c0c3y",
symbol: 'BTC'
}
]
Query the registry address of DID name.
Note: If this method is not supported, an "Unsupported Method" exception will be thrown
name: string
address string
// Query the registry address of the name
alldid.registryAddress('leon.wallet').then(console.log)
alldid.registryAddress('π.sol').then(console.log)
// The printed result would be like:
// leon.wallet
"0xa9a6A3626993D487d2Dbda3173cf58cA1a9D9e9f"
// π.sol
"58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"
TBD
TBA
If you have questions or need help with AllDID.js, there are several ways to get assistance:
- Join the .bit community on Discord channel.
- File issues on the GitHub repository for AllDID.js.
We welcome contributions to AllDID.js! If you are interested in helping to improve the project, there are several ways you can contribute:
- Report bugs or suggest improvements by opening an issue on the GitHub repository.
- Submit a pull request with your changes to the code.
Please note that AllDID.js SDK is still under development, so any contribution (including pull requests) is welcome.
AllDID.js (including all dependencies) is protected under the MIT License. This means that you are free to use, modify, and distribute the software as long as you include the original copyright and license notice. Please refer to the license for the full terms.