Sound SDK
Interacting with editions

Sound Edition Version Checks

Due to breaking changes between editions, it is important to check the edition version before using them if you are not sure pre-emptively what version your contract was deployed.

As a rule of thumb, if your contract was deployed October 10th 2023 or later, you should use the V2 edition version of the SDK and you can skip all the v1 functions, and also lower your bundle size (with automatic tree shaking if available or manually importing only used functions).

edition.ts
import { soundEditionVersionPublicActions } from '@soundxyz/sdk'
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
 
export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http('...'),
}).extend(soundEditionVersionPublicActions)
 
// ...
 
const { isSoundEditionV1, isSoundEditionV2 } = await publicClient.soundEditionVersion({
  contractAddress,
})

Sound Edition V2 (Tiered Editions)

Limited Edition vs Forever Edition

Conceptually on https://www.sound.xyz when the tier is 1 we consider it as Limited Edition and when tier is 0 we consider it as Forever Edition. But the contract allows any non-zero tier to be part of a Sound Contract, but currently our upload tool only handles tier 1 and 0.

Usage

After extending the viem instance, you will have full type-safety and autocomplete on the sub-path publicClient.editionV2 and walletClient.editionV2.

You can also check github.com/soundxyz/sdk/examples/nextjs/src/app/v2/page.tsx as a real world example

edition.ts
import {
  editionV2PublicActionsCreate,
  editionV2PublicActionsInfo,
  editionV2PublicActionsMint,
  editionV2WalletActionsCreate,
  editionV2WalletActionsMint,
  withMerkleProvider,
} from '@soundxyz/sdk'
 
import { LanyardMerkleProvider } from '@soundxyz/sdk/api/lanyard'
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet } from 'viem/chains'
 
export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http('...'),
})
  // Mint functions require to set a merkle provider for presale-access checks, if you have access to Sound API, you can use the sound api instance as merkle provider
  // .extend(withMerkleProvider(soundApi))
  .extend(withMerkleProvider(LanyardMerkleProvider))
  // Only import and add if you need to create editions
  .extend(editionV2PublicActionsCreate)
  // Information about editions
  .extend(editionV2PublicActionsInfo)
  // Minting functions
  .extend(editionV2PublicActionsMint)
 
const walletClient = createWalletClient({
  transport: http('...'),
  account,
  chain: mainnet,
})
  // Only import and add if you need to create editions
  .extend(editionV2WalletActionsCreate)
  // Minting functions
  .extend(editionV2WalletActionsMint)
 
// ...
 
// publicClient.editionV2.info
// publicClient.editionV2.mintSchedules
// publicClient.editionV2.mintParameters
 
// walletClient.editionV2.create
// walletClient.editionV2.mint

Sound Edition V1 (Previous Tiered Editions Breaking Change Upgrade)

After extending the viem instance, you will have full type-safety and autocomplete on the sub-path publicClient.editionV1 and walletClient.editionV1.

You can also check github.com/soundxyz/sdk/examples/nextjs/src/app/v1 as a real world example

edition.ts
import { editionV1PublicActions, withMerkleProvider, editionV1WalletActions } from '@soundxyz/sdk'
import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet } from 'viem/chains'
 
import { LanyardMerkleProvider } from '@soundxyz/sdk/api/lanyard'
 
export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http('...'),
})
  // Mint functions require to set a merkle provider for presale-access checks, if you have access to Sound API, you can use the sound api instance as merkle provider
  // .extend(withMerkleProvider(soundApi))
  .extend(withMerkleProvider(LanyardMerkleProvider))
  .extend(editionV1PublicActions)
 
const walletClient = createWalletClient({
  transport: http('...'),
  account,
  chain: mainnet,
}).extend(editionV1WalletActions)
 
// ...
 
// publicClient.editionV1.info
// publicClient.editionV1.mintSchedules
// publicClient.editionV1.mintParameters
 
// walletClient.editionV1.mint