Using SDK on backend

The SDK was designed for use on the frontend side. It uses some libraries which usually are available in browser only.
To use the SDK on the server side (backend):

  1. Install dependencies:
yarn add form-data
yarn add node-fetch
  1. Add dependencies to global
global.FormData = require("form-data")
global.window = {
  fetch: require("node-fetch"),
  dispatchEvent: () => {
global.CustomEvent = function CustomEvent() {
  1. You can check our backend example which buys Ethereum NFT on testnet

Pass private key, node RPC URL, network ID, item ID for buyout and start:

BUYOUT_ITEM_ID="0x1AF7A7555263F275433c6Bb0b8FdCD231F89B1D7:102581254137174039089845694331937600507918590364933200920056519678660477714440" \
ts-node packages/sdk-examples/src/backend/ethereum/buy.ts


Rarible SDK can be used in any javascript-enabled environment including backend. You have to provide implementations for form-data and fetch