Buy NFT

How to purchase an NFT from the Wayup Marketplace

Introduction

This guide demonstrates how to find and purchase an NFT on the Wayup Marketplace using the API. The process involves two main steps:

  1. Finding an NFT listing using the get-collection-assets endpoint. See Get Collection Assets

  2. Building a purchase transaction with the build-tx endpoint

Requirements

  • A Cardano wallet with sufficient ADA

  • UTXOs from your wallet to fund the transaction. See Select UTXOs

  • Policy ID of the NFT collection you're interested in

API Request Structure

Configuration

// API endpoint for Wayup Marketplace
const BASE_URL = "https://prod.api.ada-anvil.app/marketplace/api";

// NFT Collection to purchase from
const POLICY_ID = "6fb0ce0d80bce539333b0b16f4a29a0d40c786249f86850d3a36fa01";

// Wallet address to receive change and NFT
const BUYER_CHANGE_ADDRESS = "addr1qx33ycd2ymg02dxh6vnnf8dsk54l8ranr9cfjk9qrlj3309c69jc4n8h3uvnczncaqu2sm03pl99h99n75uvtl3mhv0q3z8s8m";

// UTXOs from your wallet to fund the transaction
const BUYER_UTXOS: string[] = [
    "828258204baa167631a62343cc4f37f9313ee05d6149b1fda39fd563e12832c8dd49fac90182583901a31261aa26d0f534d7d327349db0b52bf38fb319709958a01fe518bcb8d1658accf78f193c0a78e838a86df10fca5b94b3f538c5fe3bbb1e821a001344eea1581c6fb0ce0d80bce539333b0b16f4a29a0d40c786249f86850d3a36fa01a24f4646506f776572436f72657336323901504646506f776572436f7265733132343801",
    "828258204baa167631a62343cc4f37f9313ee05d6149b1fda39fd563e12832c8dd49fac90282583901a31261aa26d0f534d7d327349db0b52bf38fb319709958a01fe518bcb8d1658accf78f193c0a78e838a86df10fca5b94b3f538c5fe3bbb1e1a005b1fe1",
    "82825820daac1d3b80dcab8817c2f02f2d43ab2b33a4e74419679939eb8aa5f70b03f35c0182583901a31261aa26d0f534d7d327349db0b52bf38fb319709958a01fe518bcb8d1658accf78f193c0a78e838a86df10fca5b94b3f538c5fe3bbb1e821a007a089da1581c6fb0ce0d80bce539333b0b16f4a29a0d40c786249f86850d3a36fa01a1504646506f776572436f7265733137323001"
];

Type Definitions

Implementation

Step 1: Find Available Listings

First, query the API to find NFTs for sale, sorted by price:

Step 2: Build the Purchase Transaction

Next, construct a purchase transaction using the listing:

Running the Example

Example Output

The Complete File

See our examples repository for the complete file: buy-nft-test.tsarrow-up-right

chevron-rightpurchase-nft-test.tshashtag

Next Steps

After building the transaction:

  1. Sign the transaction hex with your wallet. See Sign Transactionsarrow-up-right

  2. Submit the signed transaction using the /submit endpoint. See Submit Transactions

  3. Wait for confirmation on the blockchain

Last updated

Was this helpful?