-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(release): publish - project: @justaname.id/react 0.3.40 - project: @justaname.id/sdk 0.2.37 - project: create-justaname-app 0.3.34 * chore(release): publish - project: @justaname.id/react 0.3.41 - project: @justaname.id/sdk 0.2.38 - project: create-justaname-app 0.3.35 * chore(release): publish - project: @justaname.id/react 0.3.42 - project: @justaname.id/sdk 0.2.39 - project: create-justaname-app 0.3.36 * feat: address decoder upgrade * feat: get communities * chore(release): publish - project: @justaname.id/react 0.3.43 - project: @justaname.id/sdk 0.2.40 - project: create-justaname-app 0.3.37 * chore(release): publish - project: @justaname.id/react 0.3.44 - project: @justaname.id/sdk 0.2.41 - project: create-justaname-app 0.3.38 * chore(release): publish - project: @justaname.id/react 0.3.45 - project: @justaname.id/sdk 0.2.42 - project: create-justaname-app 0.3.39 * chore(release): publish - project: @justaname.id/react 0.3.46 - project: @justaname.id/sdk 0.2.43 - project: create-justaname-app 0.3.40 * chore(release): publish - project: @justaname.id/react 0.3.47 - project: @justaname.id/sdk 0.2.44 - project: create-justaname-app 0.3.41 * chore(release): publish - project: @justaname.id/react 0.3.48 - project: @justaname.id/sdk 0.2.45 - project: create-justaname-app 0.3.42 * feat: how to docs (#18) * feat: community paginated and use address subname --------- Co-authored-by: Ghadi Mhawej <[email protected]>
- Loading branch information
Showing
77 changed files
with
1,194 additions
and
1,562 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
JUSTANAME_API_KEY=your_api_key | ||
JUSTANAME_CHAIN_ID=your_chain_id | ||
JUSTANAME_DOMAIN=yourwebsite | ||
JUSTANAME_ORIGIN=yourwebsite.com | ||
JUSTANAME_ORIGIN=yourwebsite.com | ||
JUSTANAME_ENS_DOMAIN=yourens.eth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
id: resolving-a-name | ||
title: Resolving a Name | ||
sidebar_label: Resolving a Name | ||
slug: /how-to/resolving-a-name | ||
--- | ||
|
||
# Resolving Names | ||
|
||
## Overview | ||
This guide demonstrates how to resolve names to their attached addresses in a chain-agnostic manner. This means any address from any blockchain can be associated with a name, and the name can consequently be resolved to any of these attached addresses. | ||
|
||
We'll cover two methods for achieving this: | ||
1. Using the `@ensdomains/ensjs` package. | ||
2. Using the `@justaname.id/sdk` package. | ||
|
||
## Method 1: Using `@ensdomains/ensjs` | ||
The `@ensdomains/ensjs` package is a powerful tool that enables domain name resolution, particularly for the Ethereum Name Service (ENS). Below, you'll find an example of how to use this package to resolve multiple blockchain addresses associated with a single domain name. | ||
|
||
### Installation | ||
First, ensure you have the necessary packages: | ||
```sh | ||
npm install @ensdomains/ensjs viem | ||
``` | ||
|
||
### Code Example | ||
Below is an example code snippet using `@ensdomains/ensjs`: | ||
```javascript | ||
import { createPublicClient, http } from "viem"; | ||
import { mainnet } from "viem/chains"; | ||
import { addEnsContracts } from "@ensdomains/ensjs"; | ||
import { getRecords } from "@ensdomains/ensjs/public"; | ||
|
||
const client = createPublicClient({ | ||
chain: addEnsContracts(mainnet), | ||
transport: http(), | ||
}); | ||
|
||
const main = async () => { | ||
const result = await getRecords(client, { | ||
name: "justghadi.justan.id", | ||
texts: [ | ||
"com.twitter", | ||
"avatar", | ||
"email" | ||
], | ||
coins: ["60", "0", "2147483658", "2147483785", "2147492101", "2147542792"], | ||
contentHash: true, | ||
}); | ||
console.log({result}); | ||
}; | ||
|
||
main(); | ||
``` | ||
|
||
### Explanation | ||
- **Texts**: These are the traditional DNS records like `twitter handle`, `avatar`, `email`, etc. | ||
- **Coins**: These represent different blockchain addresses: | ||
- `"60"`: Ethereum | ||
- `"0"`: Bitcoin | ||
- `"2147483658"`: Optimism | ||
- `"2147483785"`: Polygon | ||
- `"2147492101"`: Base | ||
- `"2147542792"`: Linea | ||
- The `main()` function fetches and prints the records associated with the specified name. | ||
|
||
## Method 2: Using `@justaname.id/sdk` | ||
The `@justaname.id/sdk` package is another versatile tool for name resolution, which supports the resolution of names across different chains. | ||
|
||
### Installation | ||
Ensure you have the required package: | ||
```sh | ||
npm install @justaname.id/sdk | ||
``` | ||
|
||
### Code Example | ||
Below is an example code snippet using `@justaname.id/sdk`: | ||
```javascript | ||
import { JustaName } from "@justaname.id/sdk"; | ||
|
||
const main = async () => { | ||
const justaName = await JustaName.init({}); | ||
|
||
const records = await justaName.subnames.getRecordsByFullName({ | ||
fullName: "justghadi.justan.id", | ||
chainId: 1, | ||
providerUrl: "https://ethereum-rpc.publicnode.com", | ||
}); | ||
|
||
console.log({ records }); | ||
}; | ||
|
||
main(); | ||
``` | ||
|
||
### Explanation | ||
- **fullName**: The full name to resolve. | ||
- **chainId**: The blockchain ID. `1` stands for Ethereum mainnet. | ||
- **providerUrl**: URL of the ethereum RPC provider. | ||
- The `main()` function initializes the `JustaName` SDK and fetches all records associated with the specified name. | ||
|
||
**Note**: The `@justaname.id/sdk` package will return all records attached to the name, making it a comprehensive solution to retrieve all necessary information linked to a name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
id: coin-types | ||
title: Coin Types | ||
sidebar_label: Coin Types | ||
slug: /how-to/coin-types | ||
--- | ||
|
||
# Understanding Coin Types in EVM and Multi-Chain Ecosystems | ||
|
||
This markdown page provides a comprehensive explanation on how to understand and use coin types, particularly within EVM (Ethereum Virtual Machine) compatible chains. We will reference formal specifications such as **[SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md)** for non-EVM coins and **ENSIP-11** for EVM compatible chains. | ||
|
||
## Introduction to Coin Types | ||
|
||
Coin types are identifiers used to uniquely specify the address encoding types of various cryptocurrencies, particularly in the context of deterministic wallets. These identifiers ensure that addresses for different types of coins are distinct and non-colliding. | ||
|
||
## Coin Types for Non-EVM Chains | ||
|
||
For non-EVM compatible chains, coin types are assigned according to the [SLIP-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) standard. This document lists various coin types and their respective cryptocurrencies. | ||
|
||
## Coin Types for EVM-Compatible Chains | ||
|
||
For EVM compatible chains, the **ENSIP-11** specification extends the basic multi-coin resolution principles introduced in **ENSIP-9**. ENSIP-11 provides a systematic way to derive and manage coin types for EVM chains. | ||
|
||
### Abstract | ||
|
||
ENSIP-11 dedicates a designated range for coin types for EVM chains, ensuring they do not collide with non-EVM coin types. | ||
|
||
### Motivations | ||
|
||
The primary motivation of ENSIP-11 is to avoid redundant requests for adding EVM compatible chains into SLIP 44 because most of these chains inherit Ethereum's address encoding type. | ||
|
||
### Specifications | ||
|
||
- **MSB Reserved:** The most-significant bit (MSB) is reserved for EVM chain IDs. | ||
- **Coin Type Derivation:** Compute the coin type for EVM chains by bitwise-ORing the chain ID with `0x80000000`: | ||
```javascript | ||
export const evmChainIdToCoinType = (chainId: number) => { | ||
return (0x80000000 | chainId) >>> 0; | ||
} | ||
``` | ||
|
||
- **Reverse Operation:** To infer the chain ID from a coin type, bitwise-AND the coin type with `0x7fffffff`: | ||
```javascript | ||
export const coinTypeToEvmChainId = (coinType: number) => { | ||
return (0x7fffffff & coinType) >> 0; | ||
} | ||
``` | ||
|
||
### Implementation | ||
|
||
An implementation is provided in the [ensdomains/address-encoder repository](https://github.com/ensdomains/address-encoder). | ||
|
||
### Example | ||
|
||
To compute the new coin type for an EVM chain (e.g., chain ID 61): | ||
|
||
```javascript | ||
import { coinTypeToEvmChainId, evmChainIdToCoinType } from "@ensdomains/address-encoder/utils"; | ||
|
||
console.log(evmChainIdToCoinType(61)); // Outputs: 2147483709 | ||
console.log(coinTypeToEvmChainId(2147483709)); // Outputs: 61 | ||
``` | ||
|
||
### Exceptions | ||
|
||
Some EVM chains have specific considerations: | ||
|
||
- **AVAX:** AVAX has multiple chain address formats, only `c` chain is EVM compatible. | ||
- **RSK:** RSK requires additional validation. | ||
|
||
These chains will continue using coin types as defined in SLIP44. | ||
|
||
### Backward Compatibility | ||
|
||
The following EVM compatible coin types were defined before this new standard and should be appended with `_LEGACY` for backward compatibility: | ||
|
||
- NRG | ||
- POA | ||
- TT | ||
- CELO | ||
- CLO | ||
- TOMO | ||
- EWT | ||
- THETA | ||
- GO | ||
- FTM | ||
- XDAI | ||
- ETC | ||
|
||
When these are displayed, append `_LEGACY` to the coin type and mark them as read-only. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
id: how-to | ||
title: How To | ||
sidebar_label: How To | ||
slug: /how-to | ||
--- | ||
import DocCardList from '@theme/DocCardList'; | ||
|
||
<DocCardList/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
JUSTANAME_API_KEY=your_api_key | ||
JUSTANAME_CHAIN_ID=your_chain_id | ||
JUSTANAME_DOMAIN=your-ens-domain.eth | ||
JUSTANAME_ORIGIN=yoursite.com | ||
JUSTANAME_DOMAIN=yourwebsite | ||
JUSTANAME_ORIGIN=yourwebsite.com | ||
JUSTANAME_ENS_DOMAIN=yourens.eth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.