- GoTrading-js
- Table of Contents
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.
- Simple and easy-to-use API
- Real-time market data access
- Code is easy to customize and extend
- Supports Bulk Listing and Bulk Buying
GoTrading currently aggregates the following marketplaces, and we will continue to add more marketplaces in the future.
| Marketplace | Create Listings | Fulfill Listings | Create Offers | Fulfill Offers | Cancel Listings/Offers | Protocol |
|---|---|---|---|---|---|---|
| OpenSea | Yes | Yes | Yes | Yes | Yes | seaport-v1.5 |
| Blur | Yes | Yes | Yes | Yes | Yes | blur |
| LooksRare | Yes | Yes | Yes | Yes | Yes | looksrare-v2 |
| X2Y2 | Yes | Yes | Yes | Yes | Yes | x2y2 |
| Sudoswap | No | Yes | No | Yes | No | sudoswap/sudoswap-v2 |
| CryptoPunks | No | Yes | No | Yes | Yes | cryptopunks |
| Artblocks | No | Yes | No | Yes | Yes | seaport-v1.5 |
| Reservoir | No | Yes | No | Yes | Yes | seaport-v1.5 |
| ENSVision | No | Yes | No | Yes | Yes | seaport-v1.5 |
| Magically | No | Yes | No | Yes | Yes | seaport-v1.5 |
| Alienswap | No | Yes | No | Yes | Yes | seaport-v1.5 |
| Ordinals | No | Yes | No | Yes | Yes | seaport-v1.5 |
| Sound | No | Yes | No | Yes | Yes | seaport-v1.5 |
| NFTGO | Yes | Yes | Yes | Yes | Yes | seaport-v1.5/payment-processor-v2 |
GoTrading currently supports the following chains:
- Ethereum Mainnet
- Sepolia Testnet ( Comming Soon )
- Polygon Mainnet ( Comming Soon )
- 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.9With
npm:
npm install @nftgo/gotradingWith
yarn:
yarn add @nftgo/gotradingInstantiate 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.
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');}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);The Marketplace methods are used to create and fulfill listings and offers across all marketplaces.
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);},});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);},});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);},});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);},});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);},});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);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);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);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);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.
This project is licensed under the BSD-3-Clause license.