Skip to content

Instantly share code, notes, and snippets.

@0xlxy
Created September 14, 2022 03:21
Show Gist options
  • Save 0xlxy/3a6eec25d495a1416ac6e1bc86aa72fd to your computer and use it in GitHub Desktop.
Save 0xlxy/3a6eec25d495a1416ac6e1bc86aa72fd to your computer and use it in GitHub Desktop.
Script for making an offer on X2Y2
import { Signer } from 'ethers'
import { ethersWallet, init, offer } from '@x2y2-io/sdk'
import { Network } from '@x2y2-io/sdk/dist/network'
require('dotenv').config()
// https://github.com/X2Y2-io/x2y2-sdk#making-offers--collection-offers
const X2Y2_API_KEY: string = process.env.X2Y2_API_KEY || ""
const WALLET_PRIVATE_KEY: string = process.env.WALLET_PRIVATE_KEY || ""
init(X2Y2_API_KEY)
const network: Network = 'mainnet'
const signer: Signer = ethersWallet(WALLET_PRIVATE_KEY, network)
const isCollection = false
const tokenAddress = '0x3A112D86899578E63b373B6D09322E18Aed924Cb'
const tokenId = '4946'
const tokenStandard = 'erc721'
const currency = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
const price = "1000000000000000"
const expirationTime = 1682052317
// Approve WETH: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
async function makeOffer(network, signer, isCollection, tokenAddress, tokenId, tokenStandard, currency, price, expirationTime) {
console.log("start making offer")
const res = await offer({network, signer, isCollection, tokenAddress, tokenId, tokenStandard, currency, price, expirationTime})
console.log(res)
console.log("making offer succeeded")
}
makeOffer(network, signer, isCollection, tokenAddress, tokenId, tokenStandard, currency, price, expirationTime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment