Submit Transaction

How to submit signed transactions to the Wayup Marketplace

Introduction

This guide demonstrates how to submit a signed transaction to the Wayup Marketplace using the API. This step comes after you've built and signed a transaction, such as for buying an NFT, making an offer, or creating a listing.

Requirements

  • A transaction hex from a previous /build-tx call

  • A signature from your wallet after signing the transaction (optional). See Sign Transactions

API Request Structure

Configuration

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

// Replace these with your actual signature and transaction hex
// The signature comes from your wallet after signing the transaction hex
// The transaction is the hex output from a previous build-tx call
const SIGNATURE = "SIGNATURE";
const TRANSACTION = "TRANSACTION";

Type Definitions

interface SubmitPayload {
  signature: string;
  transaction: string;
}

Implementation

Step 1: Prepare the Submission Payload

First, prepare the payload with your signature and transaction hex:

// Step 1: Prepare the payload with signature and transaction
console.log("Preparing submission payload...");
const payload = {
  signature: SIGNATURE.trim(),
  transaction: TRANSACTION.trim(),
};

Step 2: Submit the Transaction

Next, submit the transaction to the API:

// Step 2: Submit the transaction
console.log("Submitting signed transaction...");
const response = await fetch(`${BASE_URL}/submit`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});

Step 3: Process the Response

Finally, process the response from the API:

// Step 3: Process the response
const result = await response.json();
console.log("Transaction submission result:", result);

// Next step: Check the transaction status on chain explorers
console.log("Check transaction status on Cardanoscan or similar explorer");

Running the Example

deno run --allow-net submit-tx.ts

Example Output

Preparing submission payload...
Submitting signed transaction...
Transaction submission result: {
  result: {
    data: {
      txHash: "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
    }
  }
}
Check transaction status on Cardanoscan or similar explorer

The Complete File

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

// Replace these with your actual signature and transaction hex
// The signature comes from your wallet after signing the transaction hex
// The transaction is the hex output from a previous build-tx call
const SIGNATURE = "a10084582a82582a5840680ddbb903f321289e96ca816aeab0eb947b";
const TRANSACTION = "84aa00d9010283825820b808df86c4bb38072dac95bddb651";

// Step 1: Prepare the payload with signature and transaction
console.log("Preparing submission payload...");
const payload = {
  signature: SIGNATURE.trim(), // Optional if TX is already signed
  transaction: TRANSACTION.trim(),
};

// Step 2: Submit the transaction
console.log("Submitting signed transaction...");
const response = await fetch(`${BASE_URL}/submit`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload),
});

// Step 3: Process the response
const result = await response.json();
console.log("Transaction submission result:", result);

// Next step: Check the transaction status on chain explorers
console.log("Check transaction status on Cardanoscan or similar explorer");

// Run this with: deno run --allow-net submit-tx.ts

Best Practices

  1. Transaction Verification: Always verify the transaction hex before signing

  2. Signature Format: Ensure the signature is properly formatted from your wallet

  3. Error Handling: Check the response for any errors before assuming success

  4. Chain Validation: Always verify the transaction was confirmed on the blockchain

End-to-End Flow

  1. Build a transaction using a specific endpoint (buy, create listing, make offer)

  2. Sign the transaction with your wallet

  3. Submit the signed transaction using this guide

  4. Verify the transaction on a blockchain explorer

Last updated

Was this helpful?