NFT

NFT React & React Native Hooks

Import hooks

In order to use the function below, you need to import the hooks for React or React native.

Import React Hooks

import { hooks } from '@paytweed/frontend-sdk-react'

Buy with fiat

Description

Returns a url of a widget where the user can buy a Token using a credit / debit card see the NFT Checkout integration guidelines for more details about this feature.

Parameters

NameTypeRequiredDescription

nftID

String

✔️

The ID of the NFT, the widget will collect the data to present the NFT from the backend

data

Record<any, any>

Extra data that diffuses to the backend

toWalletAddress

String

The wallet address that the NFT will be send to, If the wallet was created by tweed the wallet address will be populated automatically.

Return type

Promise<string>

Example of usage

await sdk.nft.buyWithFiat({
  nftId: '1',
  toWalletAddress: '0x123456789',
})

Get balance

Description

Returns a list of tokens owned by the user's wallet for multiple blockchains

Parameters

NameTypeRequiredDefaultDescription

blockchainIds

String[]

defaultBlockchainIds

Blockchain ids

Data type

Promise<{
  [blockchainId: string]: {
      tokenAddress: string,
      tokenTitle: string
      tokenMedia: { gateway: string, raw: string}[],
      tokenId: string
  }[]
}>

Usage Example

const { data, error, loading } = hooks.useNftBalance()
// or
const { data, error, loading } = await hooks.useNftBalance({ blockchainIds: ['ethereum', 'polygon'] })

Response Example

{
  "ethereum": [
    {
      "tokenAddress": "0x36436b6326a893d600aa9ad99317cc9d53b430c5",
      "tokenMedia": [
        {
          "gateway": "https://storage.googleapis.com/nftimagebucket/tokens/0x36436b6326a893d600aa9ad99317cc9d53b430c5/preview/956.png",
          "raw": "https://storage.googleapis.com/nftimagebucket/tokens/0x36436b6326a893d600aa9ad99317cc9d53b430c5/preview/956.png"
        }
      ],
      "tokenId": "123",
      "tokenTitle": "Calvaria"
    }
  ]
}

Get transactions

Description

Returns a list of NFT transactions for multiple blockchains

Parameters

NameTypeRequiredDefaultDescription

blockchainIds

String[]

defaultBlockchainIds

Blockchain ids

Data type

Promise<{
  [blockchainId: string]: [{
    createdAt: string,
    direction: string,
    fromAddress: string,
    id: string,
    status: string,
    toAddress: string,
    tokenMetadata: {
        tokenAddress: string
        tokenId: string
        tokenMedia: {
            gateway: string
            raw: string
          }[],
        tokenTitle: string
      }
  }]
}>

Usage Example

const { data, error, loading } = useNftTransactions()
// or
const { data, error, loading } = await hooks.useNftTransactions({ blockchainIds: ['ethereum', 'polygon'] })

Data Example

{
  "ethereum": [
    {
      "createdAt": "2022-11-15T12:55:23.000Z",
      "id": "0x8e6598a271aed1dc4b1e7930207c98a2527eda49c2b6caed7dd73c23a0071648",
      "toAddress": "0x15b895d74582daea01be8e5be264243d8c9d7bb1",
      "fromAddress": "0xc1af9c48fb30fa29b0d4b1332c63c5e71e636f62",
      "direction": "incoming",
      "status": "complete",
      "tokenMetadata": {
        "tokenAddress": "0x36436b6326a893d600aa9ad99317cc9d53b430c5",
        "tokenId": "956",
        "tokenMedia": [
          {
            "gateway": "https://storage.googleapis.com/nftimagebucket/tokens/0x36436b6326a893d600aa9ad99317cc9d53b430c5/preview/956.png",
            "raw": "https://storage.googleapis.com/nftimagebucket/tokens/0x36436b6326a893d600aa9ad99317cc9d53b430c5/preview/956.png"
          }
        ],
        "tokenTitle": "Calvaria"
      }
    }
  ],
  "polygon": []
}

Last updated