npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@guptart/x2y2-sdk

v0.1.12

Published

This SDK is a JavaScript library for selling and buying on X2Y2, so you don't need to interact with the X2Y2 API and smart contracts directly.

Downloads

6

Readme

X2Y2 SDK

This SDK is a JavaScript library for selling and buying on X2Y2, so you don't need to interact with the X2Y2 API and smart contracts directly.

Getting Started

The SDK requires an X2Y2 API Key. You can request one from the Developer Hub.

Install

Install with

yarn add @x2y2-io/sdk

or

npm install @x2y2-io/sdk --save

Initiating SDK

Call init with your API Key and then initiate an ethers.Signer instance to interact with user's wallet:

import { Signer } from 'ethers'
import { ethersWallet, init } from '@x2y2-io/sdk'
import { Network } from '@x2y2-io/sdk/network'

init(YOUR_API_KEY)

const network: Network = 'mainnet'
const signer: Signer = ethersWallet(WALLET_PRIVATE_KEY, network)

Making Offers / Collection Offers

To make a buy offer, call the offer method. Set the isCollection to true and tokenId to a empty string to make a collection offer.

await offer({
  network,
  signer: buyer, // Signer of the buyer
  isCollection: false, // bool, set true for collection offer
  tokenAddress, // string, contract address of NFT collection
  tokenId, // string, token ID of the NFT, use empty string for collection offer
  currency: weth, // string, contract address of WETH, '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
  price, // string, eg. '1000000000000000000' for 1 WETH
  expirationTime, // number, the duration of offer, in seconds.
})

Creating Listings

To creat a fixed-price listing for a single item, call the list method.

await list({
  network,
  signer: seller, // Signer of the seller
  tokenAddress, // string, contract address of NFT collection
  tokenId, // string, token ID of the NFT
  price, // string, eg. '1000000000000000000' for 1 WETH
  expirationTime, // number, the duration for listing, in seconds.
})

Cancel listing

To cancel a listing, call the cancelList method.

await cancelList({
  network,
  signer: seller, // Signer of the seller
  tokenAddress, // string, contract address of NFT collection
  tokenId, // string, token ID of the NFT
})

Buying

To purchase a fixed-price listing, call the buy method.

await buy({
  network,
  signer: buyer, // Signer of the buyer
  tokenAddress, // string, contract address of NFT collection
  tokenId, // string, token ID of the NFT
  price, // string, the price of an existing listing order, eg. '1000000000000000000' for 1 WETH
})

Cancel offer

To cancel a buy offer or a collection offer, call the cancelOffer method.

await cancelOffer({
  network,
  signer: buyer, // Signer of the buyer
  orderId, // number, id of the offer
})

Accept offer

To accept a buy offer or a collection offer, call the acceptOffer method.

await acceptOffer({
  network,
  signer: buyer, // Signer of the buyer
  orderId, // number, id of the offer
  tokenId, // string | undefined, token ID of your NFT, only necessary when accepting a collection offer
})

Overriding Gas

For methods that submit transactions like cancelList, buy, cancelOffer and acceptOffer, it's possible to overrides ethers variables like gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, etc.

await acceptOffer({
},
{
  maxFeePerGas: ethers.utils.parseUnits('10', 'gwei'), // 10 gwei
})

Contributing

X2Y2 welcomes contributions in the form of GitHub issues and pull-requests.