Sound SDK
Getting Started

Sound SDK

Official Sound development tools for the JavaScript ecosystem, with first-class support of TypeScript (opens in a new tab) and ESM (opens in a new tab)

Sound SDK Github repo (opens in a new tab)

Install

@soundxyz/sdk @soundxyz/sdk (opens in a new tab)

@soundxyz/sound-protocol @soundxyz/sound-protocol (opens in a new tab)

pnpm add @soundxyz/sdk @soundxyz/sound-protocol
yarn add @soundxyz/sdk @soundxyz/sound-protocol
npm install @soundxyz/sdk @soundxyz/sound-protocol

Usage

This library is designed to be isomorphic, so that it can be used both on server-side or client-side leveraging the ethers.js (opens in a new tab) ecosystem.

On client-side it can be used alongside web3 integrations that follow ethers (opens in a new tab) like wagmi (opens in a new tab), which allows connecting the user's wallet and using the contracts directly from the browsers.

On server-side it's required to use an ethers supported provider (opens in a new tab), we use and recommend Alchemy (opens in a new tab).

Example

You can also visit our github.com/soundxyz example (opens in a new tab) which contains more comprehensive examples on how you can interact with the Sound SDK

SoundClient

Most of the library is contained within SoundClient.

import { useAccount } from 'wagmi'
 
import { SoundClient } from '@soundxyz/sdk'
 
function Component() {
  const account = useAccount()
  // ...
 
  const client = SoundClient({
    async signer() {
      const signer = await account.connector.getSigner()
 
      // You need to validate that this situation doesn't really happen on a normal flow
      if (!signer) throw Error('Missing signer')
 
      return signer
    },
  })
}
import { StaticJsonRpcProvider } from '@ethersproject/providers'
import { SoundClient } from '@soundxyz/sdk'
 
const provider = new StaticJsonRpcProvider({
  url: '[__]',
  allowGzip: true,
})
 
const client = SoundClient({
  provider,
})

Sound.xyz API

The SDK provides direct connection with www.sound.xyz (opens in a new tab) API, which needs an API Key. The usage is optional, but certain functions like extra information or processed indexed data will require it.

To get an API Key contact us on our discord server discord.gg/soundxyz (opens in a new tab)

import { SoundClient } from '@soundxyz/sdk'
import { SoundAPI } from '@soundxyz/sdk/api'
 
// ...
 
const soundAPI = SoundAPI({
  apiKey: process.env.SOUNDXYZ_API_KEY,
})
 
const client = SoundClient({
  // ...
 
  soundAPI,
})

Merkle Providers

When interacting with Merkle Drops it's required to specify merkleProvider while creating the SoundClient instance.

Currently the SDK provides integrations with Lanyard (opens in a new tab) and Sound.xyz API.

  • Lanyard
import { SoundClient } from '@soundxyz/sdk'
import { LanyardMerkleProofProvider } from '@soundxyz/sdk/merkle/lanyard'
 
// ...
 
const client = SoundClient({
  // ...
 
  merkleProvider: LanyardMerkleProofProvider,
})
  • Sound.xyz API
import { SoundClient } from '@soundxyz/sdk'
import { SoundAPI } from '@soundxyz/sdk/api'
 
// ...
 
const soundAPI = SoundAPI({
  apiKey: process.env.SOUNDXYZ_API_KEY,
})
 
// ...
 
const client = SoundClient({
  // ...
 
  // It can be the same instance used for the API integration
  soundAPI,
 
  // ...
 
  merkleProvider: soundAPI,
})