Quick Start
Learn how to integrate Self SDK into your JavaScript/TypeScript project.
Installation
Install the SDK using your preferred package manager:
-
Install using npm
npm install @selfcrypto/sdk ethers@5.7.2
-
Install using yarn
yarn add @selfcrypto/sdk ethers@5.7.2
-
Install using pnpm
pnpm add @selfcrypto/sdk ethers@5.7.2
-
Initialize the SDK
import { SelfSDK } from "@selfcrypto/sdk"; // Initialize with default configuration const sdk = new SelfSDK(); // Or with custom configuration const sdk = new SelfSDK({ rpcUrl: "https://your-rpc-url", ipfsGateway: "https://your-ipfs-gateway/ipfs/" });```
Name Resolution
-
Resolve a name to its default address i.e owner of name (NFT):
// Get the owner's address const address = await sdk.resolveName('ricomaverick') console.log(address) // 0x383D8ee00c3Ea31dd4eb6e5eCf649Bc9C08D8e31
Cross-chain Resolution
-
Get addresses for different chains:
// Get ETH address const ethAddress = await sdk.resolveCrossChain('ricomaverick', 'eth') console.log(ethAddress) // 0x383D8ee00c3Ea31dd4eb6e5eCf649Bc9C08D8e31 // Get Nimiq address const nimAddress = await sdk.resolveCrossChain('ricomaverick', 'nim') console.log(nimAddress) // NQ47 04KA G5JP DHBQ 22HD NMAR S0KN E9N0 P1YX
Metadata Resolution
-
Get complete metadata for a name:
const metadata = await sdk.resolveMetadata("ricomaverick"); console.log(metadata); // Output: { name: 'ricomaverick', description: '', image: 'ipfs://bafybeibgf3k6srras7ioseakj26zdnys7kavllisdq4syxua6qlc2uvrvm/ricomaverick.png', foreignAddresses: { matic: { name: 'Polygon', symbol: 'matic', address: '0x383D8ee00c3Ea31dd4eb6e5eCf649Bc9C08D8e31' }, eth: { name: 'Ethereum', symbol: 'eth', address: '0x383D8ee00c3Ea31dd4eb6e5eCf649Bc9C08D8e31' }, arb: { name: 'Arbitrum', symbol: 'arb', address: '0x383D8ee00c3Ea31dd4eb6e5eCf649Bc9C08D8e31' }, avax: { name: 'Avalanche', symbol: 'avax', address: '0x383D8ee00c3Ea31dd4eb6e5eCf649Bc9C08D8e31' }, bsc: { name: 'BSC', symbol: 'bsc', address: '0x383D8ee00c3Ea31dd4eb6e5eCf649Bc9C08D8e31' }, nim: { name: 'Nimiq', symbol: 'nim', address: 'NQ47 04KA G5JP DHBQ 22HD NMAR S0KN E9N0 P1YX' } }, email: 'enrique.ferrater@selfcrypto.io', createdAt: '2024-11-22T16:47:03.780Z' }
Next Steps
- Learn about SDK Configuration
- View all available SDK Methods and Types
For production deployments, it's recommended to provide your own RPC URL and IPFS gateway to ensure reliable performance.