GETTING STARTED
Quick Start
Start reading data from the Ivy chain in minutes (with viem examples).
This guide gets you reading data from the Ivy chain in a few minutes. The examples use viem; you can do the same with ethers or wagmi.
#1. Install
npm install viem
#2. Create a public client
A read client connected to Kaia mainnet:
import {createPublicClient, http, defineChain} from "viem";
export const kaia = defineChain({
id: 8217,
name: "Kaia",
nativeCurrency: {decimals: 18, name: "Kaia", symbol: "KAIA"},
rpcUrls: {default: {http: ["https://public-en.node.kaia.io"]}},
blockExplorers: {default: {name: "Kaiascan", url: "https://kaiascan.io"}},
});
export const client = createPublicClient({chain: kaia, transport: http()});
#3. Read a wallet's Ivy identity
Every user has an ivyId (an ERC-721 token id). From wallet to ivyId:
const IVY_REGISTRY = "0x43522E0aB410246C014359B7F5c55F7a196dddFc";
const ivyId = await client.readContract({
address: IVY_REGISTRY,
abi: [{
type: "function",
name: "ivyIdOf",
stateMutability: "view",
inputs: [{name: "wallet", type: "address"}],
outputs: [{type: "uint256"}],
}],
functionName: "ivyIdOf",
args: ["0x0000000000000000000000000000000000000000"], // the user's wallet
});
// If ivyId === 0n this wallet has no Ivy account.
console.log("ivyId:", ivyId);
#4. Read the profile
const profile = await client.readContract({
address: IVY_REGISTRY,
abi: [{
type: "function",
name: "profileOf",
stateMutability: "view",
inputs: [{name: "ivyId", type: "uint256"}],
outputs: [{
type: "tuple",
components: [
{name: "ivyId", type: "uint256"},
{name: "wallet", type: "address"},
{name: "displayName", type: "string"},
{name: "verified", type: "bool"},
{name: "referrerIvyId", type: "uint256"},
{name: "activeUsernameTokenId", type: "uint256"},
{name: "lastUsernameChange", type: "uint256"},
{name: "createdAt", type: "uint256"},
],
}],
}],
functionName: "profileOf",
args: [ivyId],
});
console.log(profile.displayName, profile.verified);
#Next
- Contract Addresses: every address in one table.
- Integrating with viem: sending transactions (writes).
- Identity & Username: the whole identity model.
Takıldığın bir yer mi var?
Teknik destek, entegrasyon ve ortaklık için ekibe ulaş: info@ivy.live