1.1.2 • Published 1 year ago

solanart-global-offer v1.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Introduction

Solanart Global Offers give you the possibility to place a offer on an entire collection of NFT, any holders in that specific collection will be able to accept your offer.

Every function are typed for a seamless integration process

Installation

NPM:

npm i solanart-global-offer

Yarn:

yarn add solanart-global-offer

API

To fetch Global offer easily, you can use our API: Solanart Global Offer API Documentation:

Create a global offer Transaction

import { userGlobalOffer } from "solanart-global-offer";

const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");

const globalOffer = new userGlobalOffer(connection, wallet)

const { instruction, escrowAccount } = await globalOffer.createGlobalOffer(
  price * LAMPORTS_PER_SOL, // Amount in lamport of your offer
  collectionAddress,        // Collection address from the global offer program
  attributes || []          // Specific attributes targeted, [] if any
)

// Create the transaction
const tx = new Transaction()tx.add(...instruction)
tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash
tx.feePayer = wallet.publicKey
// use the escrow account to partial sign the transaction
tx.partialSign(escrowAccount)
const signed = await wallet.signTransaction(tx)

await connection.sendRawTransaction(signed.serialize())

Accept a global offer Instruction

import { userGlobalOffer } from "solanart-global-offer";

const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");

const globalOffer = new userGlobalOffer(connection, wallet)

const acceptGlobalOfferIx = await globalOffer.acceptGlobalOffer(
  tokenAddress,         // Token mint address of the NFT that will be sold
  escrowAddress,        // Escrow address of the global offer
  30 * LAMPORTS_PER_SOL // Offer in lamport, used to avoid front run
)

Cancel a global offer Instruction

import { userGlobalOffer } from "solanart-global-offer";

const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");

const globalOffer = new userGlobalOffer(connection, wallet)

const cancelGlobalOfferIx = await globalOffer.createGlobalOffer(
  escrowAddress,        // Escrow address of the global offer
)

Get collectionAddress Function

You can also get it using our API.

import { getCollectionAddressFromMint } from 'solanart-global-offer/dist/utils/index'

const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");

const collectionAddress = await getCollectionAddressFromMint(
  connection,        // Solana Connection
  tokenAddress       // NFT publicKey of the collection
)
1.1.1

1 year ago

1.1.0

1 year ago

1.0.7

1 year ago

1.1.2

1 year ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago