Skip to content

Repository files navigation

GoTrading-js

nodeDiscordTwitter

Table of Contents

Introduction

GoTrading is an open-source development kit that enables you to build your own NFT trading aggregator and marketplace. The SDK provides a comprehensive set of tools and APIs that greatly simplify the development process of a general trading aggregator like Gem.xyz or Blur.io, and allows developers to access real-time order feed and NFT transaction data. With the SDK, you can easily aggregate orders and functionality from mainstream marketplaces such as Opensea, Looksrare, Blur, x2y2, Sudoswap, etc, all in your products and communities.

Key Features

  • Simple and easy-to-use API
  • Real-time market data access
  • Code is easy to customize and extend
  • Supports Bulk Listing and Bulk Buying

Supported Marketplaces

GoTrading currently aggregates the following marketplaces, and we will continue to add more marketplaces in the future.

MarketplaceCreate ListingsFulfill ListingsCreate OffersFulfill OffersCancel Listings/OffersProtocol
OpenSeaYesYesYesYesYesseaport-v1.5
BlurYesYesYesYesYesblur
LooksRareYesYesYesYesYeslooksrare-v2
X2Y2YesYesYesYesYesx2y2
SudoswapNoYesNoYesNosudoswap/sudoswap-v2
CryptoPunksNoYesNoYesYescryptopunks
ArtblocksNoYesNoYesYesseaport-v1.5
ReservoirNoYesNoYesYesseaport-v1.5
ENSVisionNoYesNoYesYesseaport-v1.5
MagicallyNoYesNoYesYesseaport-v1.5
AlienswapNoYesNoYesYesseaport-v1.5
OrdinalsNoYesNoYesYesseaport-v1.5
SoundNoYesNoYesYesseaport-v1.5
NFTGOYesYesYesYesYesseaport-v1.5/payment-processor-v2

Supported Chains

GoTrading currently supports the following chains:

  • Ethereum Mainnet
  • Sepolia Testnet ( Comming Soon )
  • Polygon Mainnet ( Comming Soon )

Requirements

  • Node.js >= 16.14
  • web3 >= 1.8.2
  • ethers >= 5.6.9, < 6.1

You can do this by running the following commands:

npm install web3 ethers@5.6.9

Quickstart

1. Install the SDK.

With npm :

npm install @nftgo/gotrading

With yarn :

yarn add @nftgo/gotrading

2. Import and init the GoTrading SDK.

Instantiate the instance of GoTrading using your etheres provider with API key.

import{init,Config}from'@nftgo/gotrading';importWeb3from'web3';// Create a new Web3 Provider to interact with the Ethereum network.constprovider=newWeb3.providers.HttpProvider('https://mainnet.infura.io')//Replace with your own provider// Configure the necessary parameters for the Trade Aggregator API client.constconfigs: Config={apiKey: "YOUR-API-KEY",// Replace with your own API Key.web3Provider: provider,walletConfig: {address: "Your wallet address",privateKey: "Your private key"},// Replace with your wallet info.};// Create a Trade Aggregator client instance and return the utility and aggregator objects of the Trade Aggregator API.const{aggregator, utils, orderFetcher}=init(configs);

If you need to obtain an API key or a custom plan, please contact our support team. You can reach us by submitting a form, and we will respond to you within 1-2 business days.

Please note that we may need to understand your use case and requirements in order to provide you with the API key and custom plan that best suits your needs. Thank you for your interest in our service, and we look forward to working with you.

3. Fulfill Listings

import{init,Config,FulfillListingsReq}from'@nftgo/gotrading';asyncfunctiondemo(){constconfig: Config={};const{ aggregator, utils }=init(config);const{listingDTOs}=awaitorderFetcher.getOrdersByContract({contractAddress: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',// bayc contract addressorderType: OrderType.Listing})constreq: FulfillListingsReq={buyer: 'xxx',// your addressorderIds: listingDTOs.map(listingDTO=>listingDTO.orderId),safeMode: false,};// get actions, meanwhile we provide executeActions function to deal with actionsconst{ actions, executeActions }=awaitaggregator.fulfillListings(req);// case 1// RECOMMEND: use execute functions we provideawaitexecuteActions({onTaskExecuted(task){// do something with completed task infoconsole.log(task.action.name,task.status);},});console.log('success');// case 2// execute actions by yourselfconstexecutor=utils.createActionExecutor(actions);for(consttaskofexecutor){awaittask.execute();console.log(task.action.name,task.status);}console.log('success');}

SDK Core Methods

To use the GoTrading SDK, you need to initialize the SDK with your API key. After initialization, you can use the following methods to interact with the GoTrading API.

import{init,Config}from'@nftgo/gotrading';constconfig: Config={apiKey: 'YOUR-API-KEY',openSeaApiKeyConfig: {apiKey: 'YOUR-OPENSEA-API-KEY',requestsPerInterval: 10,// 10 requests per intervalinterval: 1000,// 1 second},looksRareApiKeyConfig: {apiKey: 'YOUR-LOOKSRARE-API-KEY',requestsPerInterval: 10,// 10 requests per intervalinterval: 1000,// 1 second},x2y2ApiKeyConfig: {apiKey: 'YOUR-X2Y2-API-KEY',requestsPerInterval: 10,// 10 requests per intervalinterval: 1000,// 1 second},walletConfig: {address: 'Your wallet address',privateKey: 'Your private key',},// Replace with your wallet info.};constgoTrading=init(config);

Marketplace

The Marketplace methods are used to create and fulfill listings and offers across all marketplaces.

Create Listings

import{CreateListingsReq,Orderbook,OrderKind}from'@nftgo/gotrading';constreq: CreateListingsReq={maker: 'xxx',// your addressparams: [{token: '0x97a20815a061eae224c4fdf3109731f73743db73:2',quantity: 1,weiPrice: '1000',orderKind: OrderKind.SeaportV15,orderbook: Orderbook.Opensea,listingTime: '1688625367',expirationTime: '1689858225',currency: '0x0000000000000000000000000000000000000000',automatedRoyalties: true,},{token: '0x97a20815a061eae224c4fdf3109731f73743db73:2',quantity: 1,weiPrice: '1000',orderKind: OrderKind.X2Y2,orderbook: Orderbook.X2Y2,listingTime: '1688625367',expirationTime: '1689858225',currency: '0x0000000000000000000000000000000000000000',},{token: '0x97a20815a061eae224c4fdf3109731f73743db73:2',quantity: 1,weiPrice: '1000',orderKind: OrderKind.LooksRareV2,orderbook: Orderbook.LooksRare,listingTime: '1688625367',expirationTime: '1689858225',currency: '0x0000000000000000000000000000000000000000',},{token: '0x61628d84d0871a38f102d5f16f4e69ee91d6cdd9:7248',quantity: 1,weiPrice: '1000',orderKind: OrderKind.SeaportV15,orderbook: Orderbook.Opensea,listingTime: '1688625367',expirationTime: '1689858225',currency: '0x0000000000000000000000000000000000000000',automatedRoyalties: true,},],};constresponse=awaitgoTrading.aggregator.createListings(req);awaitresponse.executeActions({onTaskExecuted(task){console.log(task.action.name,task.status);},});

Create Offers

import{CreateOffersReq,Orderbook,OrderKind}from'@nftgo/gotrading';constreq: CreateOffersReq={maker: 'xxx',// your addressparams: [{collection: '0x8d04a8c79ceb0889bdd12acdf3fa9d207ed3ff63',weiPrice: '10000000000',orderKind: OrderKind.SeaportV15,orderbook: Orderbook.Opensea,listingTime: '1689017272',expirationTime: '1688017272',quantity: 2,},{collection: '0x8d04a8c79ceb0889bdd12acdf3fa9d207ed3ff63',weiPrice: '10000000000',orderKind: OrderKind.LooksRareV2,orderbook: Orderbook.Looksrare,listingTime: '1689017272',expirationTime: '1688017272',quantity: 1,}],};constresponse=awaitgoTrading.aggregator.createOffers(req);awaitresponse.executeActions({onTaskExecuted(task){console.log(task.action.name,task.status);},});

Fulfill Listings

import{FulfillListingsReq,Orderbook,OrderKind}from'@nftgo/gotrading';constorderIds=['xxx','yyy'];// pass the listing ids you want to fulfillconstreq: FulfillListingsReq={buyer: 'xxx',// your address
orderIds,};constresponse=awaitgoTrading.aggregator.fulfillListings(req);awaitresponse.executeActions({onTaskExecuted(task){console.log(task.action.name,task.status);},});

Fulfill Offers

import{FulfillOffersReq,Orderbook,OrderKind}from'@nftgo/gotrading';constorderIds=['xxx','yyy'];// pass the offer ids you want to fulfillconstreq: FulfillOffersReq={sellerAddress: 'xxx',// your addressofferFulfillmentIntentions: [{orderId: orderIds[0],contractAddress: "0x02d66f9d220553d831b239f00b5841280ddcfaf3",tokenId: "1",quantity: 1,},{orderId: orderIds[1],contractAddress: "0x02d66f9d220553d831b239f00b5841280ddcfaf3",tokenId: "2",quantity: 1,},],};constresponse=awaitgoTrading.aggregator.fulfillOffers(req);awaitresponse.executeActions({onTaskExecuted(task){console.log(task.action.name,task.status);},});

Cancel Orders

import{CancelOrdersReq,Orderbook,OrderKind}from'@nftgo/gotrading';constcancelOrdersReq: CancelOrdersReq={callerAddress: 'xxx',// your addressorders: [{orderId: 'aaa',orderType: OrderType.Listing,},{orderId: 'bbb',orderType: OrderType.Offer,},],};constresponse=awaitgoTrading.aggregator.cancelOrders(cancelOrdersReq);awaitresponse.executeActions({onTaskExecuted(task){console.log(task.action.name,task.status);},});

OrderFetcher

Get Orders By Contract

import{OrderType,GetOrdersByContractReq}from'@nftgo/gotrading';// Get listings by contractAddressconstgetOrdersByContractReq: GetOrdersByContractReq={contractAddress: '0x97a20815a061eae224c4fdf3109731f73743db73',orderType: OrderType.Listing,};const{ listingDTOs }=awaitgoTrading.orderFetcher.getOrdersByContract(getOrdersByContractReq);// Get offers by contractAddressconstgetOffersByContractReq: GetOrdersByContractReq={contractAddress: '0x97a20815a061eae224c4fdf3109731f73743db73',orderType: OrderType.Offer,};const{ offerDTOs }=awaitgoTrading.orderFetcher.getOrdersByContract(getOrdersByContractReq);

Get Orders By NFT

import{OrderType,GetOrdersByNftsReq}from'@nftgo/gotrading';// Get listings by nftconstgetOrdersByNftsReq: GetOrdersByNftsReq={contractAddress: '0x8d04a8c79ceb0889bdd12acdf3fa9d207ed3ff63',tokenId: '1',orderType: OrderType.Listing,};const{ listingDTOs }=awaitgoTrading.orderFetcher.getOrdersByNFT(getOrdersByNftsReq);// Get offers by nftconstgetOffersByNftsReq: GetOrdersByNftsReq={contractAddress: '0x8d04a8c79ceb0889bdd12acdf3fa9d207ed3ff63',tokenId: '1',orderType: OrderType.Offer,};const{ offerDTOs }=awaitgoTrading.orderFetcher.getOrdersByNFT(getOffersByNftsReq);

Get Orders By Ids

import{OrderType,GetOrdersByIdsReq}from'@nftgo/gotrading';constgetOrdersByIdsReq: GetOrdersByIdsReq={orders: [{orderId: 'xxx',orderType: OrderType.Listing,},{orderId: 'yyy',orderType: OrderType.Offer,},],};const{ listingDTOs, offerDTOs }=awaitgoTrading.orderFetcher.getOrdersByIds(getOrdersByIdsReq);

Get Orders By Maker

import{OrderType,GetOrdersByMakerReq}from'@nftgo/gotrading';// Get listings by makerconstgetOrdersByMakerReq: GetOrdersByMakerReq={maker: 'xxx',// your addressorderType: OrderType.Listing,};const{ listingDTOs }=awaitgoTrading.orderFetcher.getOrdersByMaker(getOrdersByMakerReq);// Get offers by makerconstgetOffersByMakerReq: GetOrdersByMakerReq={maker: 'xxx',// your addressorderType: OrderType.Offer,};const{ offerDTOs }=awaitgoTrading.orderFetcher.getOrdersByMaker(getOffersByMakerReq);

Utils

Questions & Feedback

If you have any questions, issues, or feedback, please file an issue on GitHub, or drop us a message on our Discord channel for the SDK.

License

This project is licensed under the BSD-3-Clause license.

About

The all-in-one solution for NFT trading aggregators, marketplaces, automated trading and market makers.

Topics

Resources

Stars

126 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages