Purchase Link Integration

The purchase link is a way to create a pre-populated URL from the server and use it embedded within an IFrame, sent as a part of an eMail etc.

Generating the Purchase link is done using the backendSDK.NFT.buyWithFiat() backend SDK function.


Returns a URL to a widget that allow a user to buy an NFT using a traditional payments method (Payment cards, Google or Apple pay). The URL can be utilized to send your user's email a purchase link for ex.

The widget will live forever as long as it was not opened, once it was opened it will live for 24 hours, after that the widget will not be usable any longer.






The nft_object is a JSON that is used to configure the buy NFT widget and the settlement process with the platform.



redirectUriOnSuccess: When the widget is closed after a succeeded transaction the widget will redirect to the supplied URL redirectUriOnFail: When the widget is closed after a failed transaction the widget will redirect to the supplied URL

Return type

A string with a widget URL

Promise<{ widgetUrl: string; requestId: string }>

Redirect URLs

redirectUriOnSuccess - Called with the transaction hash in the `txHash` URL param
redirectUriOnFail - Called with the reason to the failure in the `error` URL param
isTopWindow - Ensures widget Redirects is top-level window.

Example of usage

  const buyNftPayload: NftPurchaseBackendPayload = {
    nftId: "123", //Can be a ramdom generated by the user
    priceInCents: 100, //Optionally 0 for freemint 
    //priceInCrypto: 10000000000000, //If the user wants to get crypto instead of fiat
    fiatCurrencyId: 'USD',
    tokenUri: '<THUMBNAIL_URI>',
    contractAddress: '<NFT_ADDRESS>',
    chain: 'ethereumSepolia', //The chainId according to the Tweed docs
    title: '<NFT_NAME>',
    description: '<NFT_DESCRIPTION>',
    abi: 'safeMint(toAddress address, tokenUri string)',
      customMintParams: {
        toWalletAddress: "<WALLET_ADDRESS>", 
        tokenUri: "<TOKEN_URI>"
  // optional
  const widgetRedirectUris: BackendWidgetRedirectUri = {
    redirectUriOnSuccess: 'https://www.redirectUriOnSuccess.com',
    redirectUriOnFail: 'https://www.redirectUriOnFail.com/',

  const widgetUrl = await backendSDK.nft.buyWithFiat(buyNftPayload, widgetRedirectUris)
  console.log({ widgetUrl })

*The ABI of the above example is just an example, Tweed support any ABI function and parametes without any limitations.

Last updated