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)

NOTE: Until @soundxyz/sdk is released as >=1.0.0, it's considered beta, and any new release until then might contain a breaking change.

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).

SoundClient

Most of the library is contained within SoundClient, which based on the given signer or provider certain functions are available.

import { useAccount } from 'wagmi'
 
import { SoundClient } from '@soundxyz/sdk'
 
function Component() {
  const account = useAccount()
  // ...
 
  const signer = await account.connector?.getSigner()
 
  // ...
 
  const client = SoundClient({
    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 getting associated audio or images 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,
})