Create your own whitelabel marketplace that enables users to buy and sell any digital assets.

Example

import { ThirdwebSDK } from "@thirdweb-dev/sdk";

const sdk = new ThirdwebSDK("{{chainName}}");
const contract = await sdk.getContract("{{contract_address}}", "marketplace");

Hierarchy

  • MarketplaceV3

Implements

  • UpdateableNetwork

Constructors

  • Parameters

    • network: NetworkInput
    • address: string
    • storage: ThirdwebStorage<IpfsUploadBatchOptions>
    • options: undefined | {
          clientId?: string;
          gasSettings?: { maxPriceInGwei?: number | undefined; speed?: "standard" | "fast" | "fastest" | undefined; };
          gasless?: ({ openzeppelin: { relayerUrl: string; relayerForwarderAddress?: string | undefined; useEOAForwarder?: boolean | undefined; domainName?: string | undefined; domainVersion?: string | undefined; }; experimentalChainlessSupport?: boolean | undefined; }) | ({ biconomy: { apiId: string; apiKey: string; deadlineSeconds?: number | undefined; }; });
          gatewayUrls?: string[];
          readonlySettings?: { rpcUrl: string; chainId?: number | undefined; };
          secretKey?: string;
          supportedChains?: ({ rpc: string[]; chainId: number; nativeCurrency: { symbol: string; name: string; decimals: number; }; slug: string; })[];
      } = {}
    • abi: objectInputType<{
          inputs: ZodDefault<ZodArray<ZodObject<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, "strip", ZodAny, objectOutputType<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, ZodAny, "strip">, objectInputType<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, ZodAny, "strip">>, "many">>;
          name: ZodDefault<ZodString>;
          outputs: ZodDefault<ZodArray<ZodObject<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, "strip", ZodAny, objectOutputType<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, ZodAny, "strip">, objectInputType<{
              components: ZodOptional<ZodArray<ZodObject<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, "strip", ZodAny, objectOutputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">, objectInputType<{
                  name: ZodDefault<ZodString>;
                  type: ZodString;
              }, ZodAny, "strip">>, "many">>;
              name: ZodDefault<ZodString>;
              stateMutability: ZodOptional<ZodString>;
              type: ZodString;
          }, ZodAny, "strip">>, "many">>;
          type: ZodString;
      }, ZodAny, "strip">[]
    • chainId: number
    • contractWrapper: ContractWrapper<MarketplaceV3> = ...

    Returns MarketplaceV3

Properties

_chainId: number
abi: objectOutputType<{
    inputs: ZodDefault<ZodArray<ZodObject<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, "strip", ZodAny, objectOutputType<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, ZodAny, "strip">, objectInputType<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, ZodAny, "strip">>, "many">>;
    name: ZodDefault<ZodString>;
    outputs: ZodDefault<ZodArray<ZodObject<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, "strip", ZodAny, objectOutputType<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, ZodAny, "strip">, objectInputType<{
        components: ZodOptional<ZodArray<ZodObject<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, "strip", ZodAny, objectOutputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">, objectInputType<{
            name: ZodDefault<ZodString>;
            type: ZodString;
        }, ZodAny, "strip">>, "many">>;
        name: ZodDefault<ZodString>;
        stateMutability: ZodOptional<ZodString>;
        type: ZodString;
    }, ZodAny, "strip">>, "many">>;
    type: ZodString;
}, ZodAny, "strip">[]
app: ContractAppURI<MarketplaceV3>
contractWrapper: ContractWrapper<MarketplaceV3>
encoder: ContractEncoder<MarketplaceV3>
estimator: GasCostEstimator<MarketplaceV3>
events: ContractEvents<MarketplaceV3>
metadata: ContractMetadata<MarketplaceV3, {
    deploy: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        platform_fee_basis_points: ZodDefault<ZodNumber>;
        platform_fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        trusted_forwarders: ZodDefault<ZodArray<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>, "many">>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        image?: any;
        name: string;
        platform_fee_basis_points: number;
        platform_fee_recipient: string;
        social_urls?: Record<string, string>;
        trusted_forwarders: string[];
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        image?: any;
        name: string;
        platform_fee_basis_points?: number;
        platform_fee_recipient?: string;
        social_urls?: Record<string, string>;
        trusted_forwarders?: string[];
    }>;
    input: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, "strip", ZodUnknown, objectOutputType<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, ZodUnknown, "strip">, objectInputType<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, ZodUnknown, "strip">>;
    output: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, "strip", ZodUnknown, objectOutputType<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, ZodUnknown, "strip">, objectInputType<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, ZodUnknown, "strip">>;
}>

Type declaration

  • deploy: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        platform_fee_basis_points: ZodDefault<ZodNumber>;
        platform_fee_recipient: ZodDefault<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>>;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
        trusted_forwarders: ZodDefault<ZodArray<ZodUnion<[ZodType<string, ZodTypeDef, string>, ZodType<`0x${string}`, ZodTypeDef, `${string}.eth` | `${string}.cb.id`>]>, "many">>;
    }, "strip", ZodTypeAny, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        image?: any;
        name: string;
        platform_fee_basis_points: number;
        platform_fee_recipient: string;
        social_urls?: Record<string, string>;
        trusted_forwarders: string[];
    }, {
        app_uri?: string;
        description?: string;
        external_link?: string;
        image?: any;
        name: string;
        platform_fee_basis_points?: number;
        platform_fee_recipient?: string;
        social_urls?: Record<string, string>;
        trusted_forwarders?: string[];
    }>
  • input: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, "strip", ZodUnknown, objectOutputType<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, ZodUnknown, "strip">, objectInputType<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodUnion<[ZodUnion<[ZodTypeAny, ZodObject<{
            data: ZodUnion<[ZodTypeAny, ZodString]>;
            name: ZodString;
        }, "strip", ZodTypeAny, {
            data?: any;
            name: string;
        }, {
            data?: any;
            name: string;
        }>]>, ZodString]>>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, ZodUnknown, "strip">>
  • output: ZodObject<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, "strip", ZodUnknown, objectOutputType<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, ZodUnknown, "strip">, objectInputType<{
        app_uri: ZodOptional<ZodString>;
        description: ZodOptional<ZodString>;
        external_link: ZodOptional<ZodString>;
        image: ZodOptional<ZodString>;
        name: ZodString;
        social_urls: ZodOptional<ZodRecord<ZodString, ZodString>>;
    }, ZodUnknown, "strip">>
platformFees: ContractPlatformFee<MarketplaceV3>
roles: ContractRoles<MarketplaceV3, "admin" | "lister" | "asset">
storage: ThirdwebStorage<IpfsUploadBatchOptions>
contractRoles: readonly ["admin", "lister", "asset"] = MARKETPLACE_CONTRACT_ROLES

Accessors

  • get directListings(): MarketplaceV3DirectListings<DirectListingsLogic>
  • Direct listings

    Returns MarketplaceV3DirectListings<DirectListingsLogic>

    Remarks

    Create and manage direct listings in your marketplace.

    // Data of the listing you want to create
    const listing = {
    // address of the contract the asset you want to list is on
    assetContractAddress: "0x...",
    // token ID of the asset you want to list
    tokenId: "0",
    // how many of the asset you want to list
    quantity: 1,
    // address of the currency contract that will be used to pay for the listing
    currencyContractAddress: NATIVE_TOKEN_ADDRESS,
    // The price to pay per unit of NFTs listed.
    pricePerToken: 1.5,
    // when should the listing open up for offers
    startTimestamp: new Date(Date.now()),
    // how long the listing will be open for
    endTimestamp: new Date(Date.now() + 5 * 24 * 60 * 60 * 1000),
    // Whether the listing is reserved for a specific set of buyers.
    isReservedListing: false
    }

    const tx = await contract.directListings.createListing(listing);
    const receipt = tx.receipt; // the transaction receipt
    const id = tx.id; // the id of the newly created listing

    // And on the buyers side:
    // The ID of the listing you want to buy from
    const listingId = 0;
    // Quantity of the asset you want to buy
    const quantityDesired = 1;

    await contract.directListings.buyFromListing(listingId, quantityDesired);
  • get englishAuctions(): MarketplaceV3EnglishAuctions<EnglishAuctionsLogic>
  • Auctions

    Returns MarketplaceV3EnglishAuctions<EnglishAuctionsLogic>

    Remarks

    Create and manage auctions in your marketplace.

    Example

    // Data of the auction you want to create
    const auction = {
    // address of the contract of the asset you want to auction
    assetContractAddress: "0x...",
    // token ID of the asset you want to auction
    tokenId: "0",
    // how many of the asset you want to auction
    quantity: 1,
    // address of the currency contract that will be used to pay for the auctioned tokens
    currencyContractAddress: NATIVE_TOKEN_ADDRESS,
    // the minimum bid that will be accepted for the token
    minimumBidAmount: "1.5",
    // how much people would have to bid to instantly buy the asset
    buyoutBidAmount: "10",
    // If a bid is made less than these many seconds before expiration, the expiration time is increased by this.
    timeBufferInSeconds: "1000",
    // A bid must be at least this much bps greater than the current winning bid
    bidBufferBps: "100", // 100 bps stands for 1%
    // when should the auction open up for bidding
    startTimestamp: new Date(Date.now()),
    // end time of auction
    endTimestamp: new Date(Date.now() + 5 * 24 * 60 * 60 * 1000),
    }

    const tx = await contract.englishAuctions.createAuction(auction);
    const receipt = tx.receipt; // the transaction receipt
    const id = tx.id; // the id of the newly created auction

    // And on the buyers side:
    // The auction ID of the asset you want to bid on
    const auctionId = 0;
    // The total amount you are willing to bid for auctioned tokens
    const bidAmount = 1;

    await contract.englishAuctions.makeBid(auctionId, bidAmount);
  • get offers(): MarketplaceV3Offers<OffersLogic>
  • Offers

    Returns MarketplaceV3Offers<OffersLogic>

    Remarks

    Make and manage offers.

    Example

    // Data of the offer you want to make
    const offer = {
    // address of the contract the asset you want to make an offer for
    assetContractAddress: "0x...",
    // token ID of the asset you want to buy
    tokenId: "0",
    // how many of the asset you want to buy
    quantity: 1,
    // address of the currency contract that you offer to pay in
    currencyContractAddress: NATIVE_TOKEN_ADDRESS,
    // Total price you offer to pay for the mentioned token(s)
    totalPrice: "1.5",
    // Offer valid until
    endTimestamp: new Date(),
    }

    const tx = await contract.offers.makeOffer(offer);
    const receipt = tx.receipt; // the transaction receipt
    const id = tx.id; // the id of the newly created offer

    // And on the seller's side:
    // The ID of the offer you want to accept
    const offerId = 0;
    await contract.offers.acceptOffer(offerId);

Methods

Generated using TypeDoc