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.
React React Native
Import React Hooks
Copy import { hooks } from '@paytweed/frontend-sdk-react'
Import React Native Hooks
Copy import { hooks } from '@paytweed/frontend-sdk-react-native'
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
Name Type Required Description The ID of the NFT, the widget will collect the data to present the NFT from the backend
Extra data that diffuses to the backend
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
Example of usage
Copy await sdk . nft .buyWithFiat ({
nftId : '1' ,
toWalletAddress : '0x123456789' ,
})
Returns a list of tokens owned by the user's wallet for multiple blockchains
Name Type Required Default Description
Copy Promise <{
[blockchainId : string ] : {
tokenAddress : string ,
tokenTitle : string
tokenMedia : { gateway : string , raw : string }[] ,
tokenId : string
}[]
}>
Copy const { data , error , loading } = hooks .useNftBalance ()
// or
const { data , error , loading } = await hooks .useNftBalance ({ blockchainIds : [ 'ethereum' , 'polygon' ] })
Copy {
"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"
}
]
}
Returns a list of NFT transactions for multiple blockchains
Name Type Required Default Description
Copy 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
}
}]
}>
Copy const { data , error , loading } = useNftTransactions ()
// or
const { data , error , loading } = await hooks .useNftTransactions ({ blockchainIds : [ 'ethereum' , 'polygon' ] })
Copy {
"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 2 months ago