Third party helpers

It is easier, but not mandatory, to use third-party libraries to simplify calling smart contracts.

Installing ethers 5

In our examples, we will use ethers 5 to handle user wallets and Bignumber arithmetics.

You can install ethers with yarn:

yarn add ethers@5

or npm:

npm install ethers@5

Installing NFT swap SDK

To help interact with the 0x smart contract, we advise using the third party SDK NFT swap. It will facilitate calling the proper smart contract functions with the proper arguments.

You can install the SDK with yarn:

yarn add @traderxyz/nft-swap-sdk

or npm:

npm install @traderxyz/nft-swap-sdk

Initializing third-party SDKs

You will need to use your preferred authentication method to initialize an ethers signer. Our account abstraction SDK Cometh connect is available if you want to provide efficient biometric authentication.

In the following example, we will use a quick and dirty way to initialize the ethers wallet.

const provider = new ethers.providers.JsonRpcProvider('A JSON RPC URL')

const privateKey = 'user-private-key'
const signer = new ethers.Wallet(privateKey, provider)

const CHAIN_ID = 32
const nftSwapSdk = new NftSwapV4(provider, signer, CHAIN_ID)

Last updated