Skip to content

Commit 97c8257

Browse files
authored
Docs update for coins SDK (#1461)
* Docs update for coins SDK * docs re-update
1 parent 2e733b8 commit 97c8257

File tree

6 files changed

+401
-168
lines changed

6 files changed

+401
-168
lines changed

docs/pages/coins/sdk/create-coin.mdx

Lines changed: 106 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Creating Coins
22

3-
The Coins SDK provides functions to create new coins on the Zora protocol.
3+
The Coins SDK provides functions to create new coins on the Zora protocol.
44

55
### Overview
66

@@ -10,25 +10,29 @@ Creating a coin involves generating calldata through the SDK and sending a trans
1010

1111
```ts
1212
import { Address } from "viem";
13-
import { CreateConstants, ContentCoinCurrency, StartingMarketCap } from "@zoralabs/coins-sdk";
13+
import {
14+
CreateConstants,
15+
ContentCoinCurrency,
16+
StartingMarketCap,
17+
} from "@zoralabs/coins-sdk";
1418

1519
type MetadataType = {
1620
type: "RAW_URI";
1721
uri: string; // e.g., an IPFS URI
1822
};
1923

2024
type CreateCoinArgs = {
21-
creator: Address; // Creator address
22-
name: string; // Coin name (e.g., "My Awesome Coin")
23-
symbol: string; // Ticker (e.g., "MAC")
24-
metadata: MetadataType; // Metadata descriptor
25-
currency: ContentCoinCurrency; // CREATOR_COIN | CREATOR_COIN_OR_ZORA | ZORA | ETH
26-
chainId?: number; // Chain ID to deploy on (defaults to Base mainnet `8453`)
25+
creator: Address; // Creator address
26+
name: string; // Coin name (e.g., "My Awesome Coin")
27+
symbol: string; // Ticker (e.g., "MAC")
28+
metadata: MetadataType; // Metadata descriptor
29+
currency: ContentCoinCurrency; // CREATOR_COIN | CREATOR_COIN_OR_ZORA | ZORA | ETH
30+
chainId?: number; // Chain ID to deploy on (defaults to Base mainnet `8453`)
2731
startingMarketCap?: StartingMarketCap; // LOW | HIGH (defaults to LOW)
28-
platformReferrer?: Address; // Optional referral address
32+
platformReferrer?: Address; // Optional referral address
2933
additionalOwners?: Address[];
3034
payoutRecipientOverride?: Address;
31-
skipMetadataValidation?: boolean; // Skip URI validation (not recommended)
35+
skipMetadataValidation?: boolean; // Skip URI validation (not recommended)
3236
};
3337
```
3438

@@ -39,7 +43,10 @@ type CreateCoinArgs = {
3943

4044
```ts twoslash
4145
import { Address } from "viem";
42-
import { createMetadataBuilder, createZoraUploaderForCreator } from "@zoralabs/coins-sdk";
46+
import {
47+
createMetadataBuilder,
48+
createZoraUploaderForCreator,
49+
} from "@zoralabs/coins-sdk";
4350

4451
const creatorAddress = "0xYourAddress" as Address;
4552

@@ -80,8 +87,18 @@ Provide the exact `chainId` you intend to deploy on (e.g., Base mainnet `8453`).
8087
#### High‑level: send transaction and wait for receipt
8188

8289
```ts twoslash
83-
import { createCoin, CreateConstants, ContentCoinCurrency } from "@zoralabs/coins-sdk";
84-
import { Hex, Address, createWalletClient, createPublicClient, http } from "viem";
90+
import {
91+
createCoin,
92+
CreateConstants,
93+
ContentCoinCurrency,
94+
} from "@zoralabs/coins-sdk";
95+
import {
96+
Hex,
97+
Address,
98+
createWalletClient,
99+
createPublicClient,
100+
http,
101+
} from "viem";
85102
import { base } from "viem/chains";
86103

87104
const publicClient = createPublicClient({
@@ -119,11 +136,53 @@ const result = await createCoin({
119136
console.log("Transaction hash:", result.hash);
120137
console.log("Coin address:", result.address);
121138
console.log("Deployment details:", result.deployment);
139+
console.log("Chain info:", result.chain);
122140
```
123141

142+
#### Response Structure
143+
144+
The `createCoin` function returns an object with the following properties:
145+
146+
```ts
147+
type CreateCoinResult = {
148+
hash: string; // Transaction hash
149+
receipt: TransactionReceipt; // Full transaction receipt from the blockchain
150+
address?: string; // Deployed coin contract address (extracted from logs)
151+
deployment?: {
152+
// Detailed deployment information from CoinCreatedV4 event
153+
coin: string; // Coin contract address
154+
creator: string; // Creator address
155+
poolAddress: string; // Uniswap pool address
156+
// ... additional deployment details
157+
};
158+
chain: Chain; // Chain object (e.g., base, baseSepolia)
159+
};
160+
```
161+
162+
**Key Fields:**
163+
164+
- `address`: The newly deployed coin's contract address - use this to interact with the coin
165+
- `hash`: Transaction hash for tracking the deployment transaction
166+
- `receipt`: Full transaction receipt containing all logs and events
167+
- `deployment`: Complete deployment details parsed from the `CoinCreatedV4` event, including pool information
168+
- `chain`: Chain configuration object for the network where the coin was deployed
169+
124170
#### Low‑level: integrate with WAGMI using a raw transaction
125171

126-
`createCoinCall` returns `{ to, data, value }`, which can be passed to your tx‑sending flow (e.g., WAGMI `useSendTransaction`).
172+
`createCoinCall` returns an object with transaction parameters and the predicted coin address:
173+
174+
```ts
175+
type CreateCoinCallResponse = {
176+
calls: Array<{
177+
to: Address; // Target contract address (coin factory)
178+
data: Hex; // Encoded function call data
179+
value: bigint; // ETH value to send (typically 0n for coin creation)
180+
}>;
181+
predictedCoinAddress: Address; // Deterministic address where coin will be deployed
182+
};
183+
```
184+
185+
The `calls` array contains the transaction parameters that can be passed to your tx‑sending flow (e.g., WAGMI `useSendTransaction`). The `predictedCoinAddress` provides the coin's address before the transaction is sent, allowing immediate UI updates or address storage.
127186

128187
```tsx
129188
import * as React from "react";
@@ -132,28 +191,42 @@ import { Address } from "viem";
132191
import { useSendTransaction } from "wagmi";
133192
import { base } from "viem/chains";
134193

135-
const args = {
136-
creator: "0xYourAddress" as Address,
137-
name: "My Awesome Coin",
138-
symbol: "MAC",
139-
metadata: { type: "RAW_URI" as const, uri: "ipfs://bafy..." },
140-
currency: CreateConstants.ContentCoinCurrencies.ZORA,
141-
chainId: base.id,
142-
startingMarketCap: CreateConstants.StartingMarketCaps.LOW,
143-
};
144-
145-
const txCalls = await createCoinCall(args);
146-
147194
function CreateCoinButton() {
148195
const { sendTransaction, status } = useSendTransaction();
196+
const [coinAddress, setCoinAddress] = React.useState<Address | null>(null);
197+
198+
const handleCreate = async () => {
199+
const args = {
200+
creator: "0xYourAddress" as Address,
201+
name: "My Awesome Coin",
202+
symbol: "MAC",
203+
metadata: { type: "RAW_URI" as const, uri: "ipfs://bafy..." },
204+
currency: CreateConstants.ContentCoinCurrencies.ZORA,
205+
chainId: base.id,
206+
startingMarketCap: CreateConstants.StartingMarketCaps.LOW,
207+
};
208+
209+
const { calls, predictedCoinAddress } = await createCoinCall(args);
210+
211+
// Store predicted address immediately for UI updates
212+
setCoinAddress(predictedCoinAddress);
213+
console.log("Coin will be deployed at:", predictedCoinAddress);
214+
215+
// Send transaction with the first call parameters
216+
sendTransaction({
217+
to: calls[0].to,
218+
data: calls[0].data,
219+
value: calls[0].value,
220+
});
221+
};
149222

150223
return (
151-
<button
152-
disabled={status === "pending"}
153-
onClick={() => sendTransaction({ to: txCalls[0].to, data: txCalls[0].data, value: txCalls[0].value })}
154-
>
155-
{status === "pending" ? "Creating..." : "Create Coin"}
156-
</button>
224+
<div>
225+
<button disabled={status === "pending"} onClick={handleCreate}>
226+
{status === "pending" ? "Creating..." : "Create Coin"}
227+
</button>
228+
{coinAddress && <p>Coin address: {coinAddress}</p>}
229+
</div>
157230
);
158231
}
159232
```
@@ -184,4 +257,4 @@ console.log("Deployed coin address:", coinDeployment?.coin);
184257

185258
### More Information
186259

187-
See [Creating a Coin](/coins/contracts/creating-a-coin) and [Contract Architecture](/coins/contracts/architecture) for protocol‑level details.
260+
See [Creating a Coin](/coins/contracts/creating-a-coin) and [Contract Architecture](/coins/contracts/architecture) for protocol‑level details.

docs/pages/coins/sdk/queries/coin.mdx

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ The `getCoin` function retrieves detailed information about a specific coin, inc
1212

1313
```ts twoslash
1414
type GetCoinParams = {
15-
address: string; // The coin contract address
16-
chain?: number; // Optional: The chain ID (defaults to Base: 8453)
15+
address: string; // The coin contract address
16+
chain?: number; // Optional: The chain ID (defaults to Base: 8453)
1717
};
1818
```
1919

@@ -32,17 +32,25 @@ import { GetCoinResponse } from "@zoralabs/coins-sdk";
3232

3333
// The Zora20Token type is imported from the SDK's generated types.
3434
// It includes detailed information about a specific coin, such as its metadata, market data, and creator information.
35-
type Zora20Token = GetCoinResponse['zora20Token'];
35+
type Zora20Token = GetCoinResponse["zora20Token"];
3636
// ^?
3737

38-
39-
40-
41-
4238
//
43-
4439
```
4540

41+
**Key Response Fields:**
42+
43+
- `platformBlocked`: Boolean indicating whether the coin is blocked on the platform (most applications should exclude blocked coins from visibility)
44+
- `creatorProfile.platformBlocked`: Boolean indicating whether the creator's profile is blocked on the platform (most applications should exclude blocked profiles from visibility)
45+
- `address`: The coin's contract address
46+
- `name`, `symbol`: Coin identification
47+
- `marketCap`, `totalSupply`, `volume24h`: Market metrics
48+
- `tokenPrice`: Pricing information in USDC and pool token
49+
- `creatorProfile`: Profile information for the coin creator, including social accounts and avatar
50+
- `mediaContent`: Associated media like images or videos
51+
- `uniqueHolders`: Number of unique token holders
52+
- `uniswapV4PoolKey`: Uniswap V4 pool configuration details
53+
4654
### getCoins
4755

4856
The `getCoins` function retrieves information about multiple coins at once, useful for batch processing or displaying multiple coins.
@@ -54,7 +62,7 @@ type GetCoinsParams = {
5462
coins: {
5563
collectionAddress: string;
5664
chainId: number;
57-
}[]
65+
}[];
5866
};
5967
```
6068

@@ -76,10 +84,10 @@ The `getCoinHolders` function retrieves information about who holds a specific c
7684

7785
```ts twoslash
7886
type GetCoinHoldersParams = {
79-
chainId: number; // The chain ID
80-
address: string; // The coin contract address
81-
after?: string; // Optional: Pagination cursor for fetching next page
82-
count?: number; // Optional: Number of holders to return per page
87+
chainId: number; // The chain ID
88+
address: string; // The coin contract address
89+
after?: string; // Optional: Pagination cursor for fetching next page
90+
count?: number; // Optional: Number of holders to return per page
8391
};
8492
```
8593

@@ -97,11 +105,11 @@ const response = await getCoinHolders({
97105
if (response.data?.zora20Token?.tokenBalances) {
98106
const holders = response.data.zora20Token.tokenBalances.edges;
99107
console.log(`Found ${holders.length} holders`);
100-
108+
101109
holders.forEach(({ node }) => {
102110
console.log(`Address: ${node.ownerAddress}`);
103111
console.log(`Balance: ${node.balance}`);
104-
console.log(`Profile: ${node.ownerProfile?.handle || 'No profile'}`);
112+
console.log(`Profile: ${node.ownerProfile?.handle || "No profile"}`);
105113
});
106114
}
107115
```
@@ -118,10 +126,10 @@ The `getCoinSwaps` function retrieves swap activities for a specific coin, showi
118126

119127
```ts twoslash
120128
type GetCoinSwapsParams = {
121-
address: string; // The coin contract address
122-
chain?: number; // Optional: The chain ID (defaults to Base: 8453)
123-
after?: string; // Optional: Pagination cursor for fetching next page
124-
first?: number; // Optional: Number of swaps to return per page
129+
address: string; // The coin contract address
130+
chain?: number; // Optional: The chain ID (defaults to Base: 8453)
131+
after?: string; // Optional: Pagination cursor for fetching next page
132+
first?: number; // Optional: Number of swaps to return per page
125133
};
126134
```
127135

@@ -139,7 +147,7 @@ const response = await getCoinSwaps({
139147
if (response.data?.zora20Token?.swapActivities) {
140148
const swaps = response.data.zora20Token.swapActivities.edges;
141149
console.log(`Found ${swaps.length} swaps`);
142-
150+
143151
swaps.forEach(({ node }) => {
144152
console.log(`Activity: ${node.activityType}`); // "BUY" or "SELL"
145153
console.log(`Amount: ${node.coinAmount}`);
@@ -161,10 +169,10 @@ The `getCoinComments` function retrieves comments associated with a specific coi
161169

162170
```ts twoslash
163171
type GetCoinCommentsParams = {
164-
address: string; // The coin contract address
165-
chain?: number; // Optional: The chain ID (defaults to Base: 8453)
166-
after?: string; // Optional: Pagination cursor for fetching next page
167-
count?: number; // Optional: Number of comments to return per page
172+
address: string; // The coin contract address
173+
chain?: number; // Optional: The chain ID (defaults to Base: 8453)
174+
after?: string; // Optional: Pagination cursor for fetching next page
175+
count?: number; // Optional: Number of comments to return per page
168176
};
169177
```
170178

@@ -186,7 +194,6 @@ To fetch all comments for a coin, you can use pagination:
186194

187195
The response includes a `comments` array and pagination information:
188196

189-
190197
## Error Handling
191198

192199
All query functions follow the same error handling pattern. When an error occurs, the promise is rejected with an error object that includes details about what went wrong.

0 commit comments

Comments
 (0)