Skip to content

Instantly share code, notes, and snippets.

@0xlxy
Created September 14, 2022 03:37
Show Gist options
  • Save 0xlxy/906c9730f0ce3e926020a794a2c0d7d1 to your computer and use it in GitHub Desktop.
Save 0xlxy/906c9730f0ce3e926020a794a2c0d7d1 to your computer and use it in GitHub Desktop.
Script for making an offer on opensea
// if type module -> cannot use reqiure, need import
// In package.json: "type": "module",
import { OpenSeaSDK, Network } from "opensea-js";
import HDWalletProvider from "@truffle/hdwallet-provider";
import { config } from 'dotenv';
config();
// https://github.com/ProjectOpenSea/opensea-js#making-offers
const WALLET_PRIVATE_KEY = process.env.WALLET_PRIVATE_KEY
const OPENSEA_API_KEY = process.env.OPENSEA_API_KEY
const RPC_URL = process.env.RPC_URL
const provider = new HDWalletProvider(
WALLET_PRIVATE_KEY, RPC_URL
);
const openseaSDK = new OpenSeaSDK(provider, {
networkName: Network.Main,
apiKey: OPENSEA_API_KEY,
});
const tokenAddress = "0x3A112D86899578E63b373B6D09322E18Aed924Cb"
const tokenId = "4946"
const accountAddress = "0x5E113EDC0eaf00699889FC510DB121308bBA1261"
const schemaName = "ERC721"
const startAmount = 0.004
async function makeOffer(tokenAddress, tokenId, schemaName, accountAddress, startAmount) {
console.log("start making offer")
const offer = await openseaSDK.createBuyOrder({
asset: {
tokenId,
tokenAddress,
schemaName
},
accountAddress,
startAmount,
});
console.log(offer)
console.log("making offer succeeded")
}
makeOffer(tokenAddress, tokenId, schemaName, accountAddress, startAmount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment