Install Rarible SDK¶
yarn add @rarible/sdk -D
yarn add web3@1.5.0
yarn add tslib@2.3.1
If you need to initialize the wallets with ethers, you can install it like this:
yarn add ethers
To make sure the SDK is installed correctly, check version:
npm view @rarible/sdk version
Initialize wallets¶
To use SDK, you have to create a Wallet — abstraction to communicate with real blockchain wallets.
Read more about initializing wallets on Wallets page.
Using SDK on client application¶
SDK is written in TypeScript. You can use typings to explore SDK possibilities.
import { createRaribleSdk } from "@rarible/sdk"
Using SDK on server application¶
The SDK was designed for use on the frontend side. To use the SDK on the server side (backend):
-
Install packages:
yarn add tslib@2.3.1 yarn add form-data yarn add node-fetch
-
Add dependencies:
global.FormData = require("form-data") global.window = { fetch: require("node-fetch"), dispatchEvent: () => { }, } global.CustomEvent = function CustomEvent() { return }
-
Try our example to buy Ethereum NFT item on Rinkeby network.
Pass private key, node RPC URL, network ID, item ID for buyout and start:
ETH_PRIVATE_KEY="0x..." \ ETHEREUM_RPC_URL="https://rinkeby.infura.io/..." \ ETHEREUM_NETWORK_ID="4" \ BUYOUT_ITEM_ID="0x1AF7A7555263F275433c6Bb0b8FdCD231F89B1D7:102581254137174039089845694331937600507918590364933200920056519678660477714440" \ ts-node packages/sdk/example/backend/buy.ts