NFT

JavaScript NFT Functions

Buy with fiat

Description

Returns a url of a widget where the user can buy a Token NFT 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 NFTs owned by the user's wallet for multiple blockchains

Parameters

NameTypeRequiredDefaultDescription

blockchainIds

String[]

defaultBlockchainIds

Blockchain ids

Return type

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

Usage Example

const nftBalance = await sdk.nft.getBalance()
// or
const nftBalance = await sdk.nft.getBalance({ 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

Return 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 transactions = await sdk.nft.getTransactions()
// or
const transactions = await sdk.nft.getTransactions({ blockchainId: ['ethereum', 'polygon'] })

Response 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": []
}

Send to user

Description

Sends the NFT to another user on the platform by its user ID. The user will get a Sign Transaction widget to approve the transaction.

Parameters

NameTypeRequiredDefaultDescription

blockchainId

String

✔️

Blockchain

tokenAddress

String

✔️

NFT contract address

tokenId

String

✔️

NFT token id

userId

String

✔️

Id of user to send crypto to

Return type

Promise<string>

Usage Example

await sdk.nft.sendToUser({
  blockchain: 'ethereum',
  tokenAddress: '0x36436b6326a893d600aa9ad99317cc9d53b430c5',
  tokenId: '123',
  userId: '1',
})

Send to wallet

Description

Send the NFT to another wallet by its wallet address. The user will get a Sign Transaction widget to approve the transaction.

Parameters

NameTypeRequiredDefaultDescription

blockchainId

String

✔️

Blockchain

tokenAddress

String

✔️

NFT contract address

tokenId

String

✔️

NFT token id

walletAddress

String

✔️

Address of wallet to send NFT to

Return type

Promise<string>

Usage Example

await sdk.nft.sendToWallet({
  blockchain: 'ethereum',
  tokenAddress: '0x36436b6326a893d600aa9ad99317cc9d53b430c5',
  tokenId: '123',
  walletAddress: '0x15b895d74582daea01be8e5be264243d8c9d7bb1',
})

Last updated