Web
Here you'll find detailed info about the features of the Web SDK
Fetch NFTs
Fetch requested NFTs
How to import:
import { getRequestedNFTs } from '@style-protocol/sdk'How it looks like:
const getRequestedNFTs = async ({
cursor = 0,
amount = 100,
chainId = 5,
metaverseFilter = [],
typeFilter = [],
subtypeFilter = [],
})cursor: integer- Start index ofgetStakesprotocol`s function (as it uses pagination).amount: integer- Number of viewed indexes ofgetStakesprotocol`s function (as it uses pagination).chainId: integer- Chain Id to be able to use it cross-chain.metaverseFilter: string | string[]- Using for metaverse filter. Any alone strings are converted to[string]. Currently possible values are:decentranland,sandbox,somnium_space,cryptovoxels, fabwelt. Use empty array to get items from all metaverses.typeFilter: string | string[]- Using for asset type filter. Any alone strings are converted to[string]. Currently possible values are:AVATAR,WEARABLE,MISC. Use empty array to get items of all types.subtypeFilter: string | string[]- Using for asset subtype filter. Any alone strings are converted to[string]. Use empty array to get items of all types.
Return value:
If succeded:
[
{
tokenAddress: '0xc36442b4a4522e871399cd717abdd847ab11fe88',
tokenId: 36639,
payment: {
value: { type: 'BigNumber', hex: '0x014d1120d7b1600000' },
stringValue: '24',
},
paymentToken: {
address: '0x48d373E2B7f0930DAEF4C51CA63711bdD9b5C5B0',
name: 'USD Circle',
symbol: 'USDC',
},
type: 'AVATAR',
subtype: 'Other',
tailorId: '632422280100cd8980997351',
jobId: '633dd5ae8e81caae508afad9',
uri: 'https://stylexchange.mypinata.cloud/ipfs/QmVab2rT96LjdqTWEaQihj4CDVvq9bbm7bgTxUZ5b8YeVt',
bidder: '0xb396aedb7e8eea5b29501f5dba173d82458c8e17',
signature:
'0x531fa0f96276037b14f61ebd2bf1702594e5ed9a67e6261e763e2163a63352d34e57d1e9d2ebee6255da18f313a873255842d4b8d391a2da63a5fe043fb5de2e1b',
environment: '0x67701e71F9412Af1BcB2D77897F40139B6Ccc073',
metaverseId: 0,
adminSignature:
'0x5a16fe5d80fa1c9a3a4400babfba2e298465eb04e429e9ea0e2e0d52cf33aea404143ffb77e03487adb56c6d048c6e6390a98da8333adb0dd1070b98fdba4a401c',
asset: {
name: 'Derivative from Uniswap - 0.3% - USDC/SP - MIN<>100050',
description:
'StyleXchange derivative from Uniswap - 0.3% - USDC/SP - MIN<>100050 for DECENTRALAND',
image:
'https://stylexchange.mypinata.cloud/ipfs/QmdE18pYr2RE8toGZVC8PJ87ryfZ2u1pL73wX6y4Ansuz6',
animation_url:
'https://stylexchange.mypinata.cloud/ipfs/bafkreidqpr3ixz5wahwmpuoqwdhlwsraju3tz2wbf3nnopo4uexxnafgpu',
},
cid: 'QmSTGGifjf669XWEFA7RxHkTGDNS23GLXjzyHKPFFuhBV8',
numberOfDerivatives: 5,
},
]If failed:
[]Buy NFTs
Approve ERC20 tokens to protocol
Web3.js
How to import:
import { approveERC20 } from '@style-protocol/sdk'How it looks like:
const approveERC20 = async ({ web3, walletAddress, NFT, spender })web3: Web3- Web3 object from web3 library (to use user's wallet).walletAddress: string- Wallet address to use it to sign transactions.NFT: dict- Object with NFT data (element of array taken from fetch functions).spender
: approve- Spender of allowance.
Return value:
If succeded:
trueIf failed:
falseEthers.js
How to import:
import { approveERC20Ethers } from '@style-protocol/sdk'How it looks like:
const approveERC20Ethers = async ({ signer, NFT, spender })signer: Signer- Signer object from ethers library (to use user's wallet).NFT: dict- Object with NFT data (element of array taken from fetch functions).spender
: approve- Spender of allowance.
Return value:
If succeded:
trueIf failed:
falseBuy requested NFTs
Web3.js
How to import:
import { buyAndMintItem } from '@style-protocol/sdk'How it looks like:
const buyAndMintItem = async ({ web3, walletAddress, chainId, NFT })web3: Web3- Web3 object from web3 library (to use user's wallet).walletAddress: string- Wallet address to use it to sign transactions.chainId: integer- Chain Id to be able to use it cross-chain.NFT: dict- Object with NFT data (element of array taken from fetch requested NFTs function).
Return value:
If succeded:
trueIf failed:
falseEthers.js
How to import:
import { buyAndMintItemEthers } from '@style-protocol/sdk'How it looks like:
const buyAndMintItemEthers = async ({ signer, chainId, NFT })signer: Signer- Signer object from ethers library (to use user's wallet).chainId: integer- Chain Id to be able to use it cross-chain.NFT: dict- Object with NFT data (element of array taken from fetch requested NFTs function).
Return value:
If succeded:
trueIf failed:
falseFetch Models
Our protocol uses semi-decentralized storage architecture for models conneted with our NFTs, so that only the owner is able to see his NFT's model.
Get User Proof
Web3.js
How to import:
import { getUserProof } from '@style-protocol/sdk'How it looks like:
const getUserProof = async ({ web3, walletAddress, cached=true })web3: Web3- Web3 object from web3 library (to use user's wallet).walletAddress: string- Wallet address to use it to sign transactions.cached
: bool- If the userProof could be saved to the cache or not.
Return value:
If succeded:
{
signature: "0x00",
walletAddress: "0x00",
}If failed:
ErrorEthers.js
How to import:
import { getUserProofEthers } from '@style-protocol/sdk'How it looks like:
const getUserProofEthers = async ({ signer, cached=true})signer: Signer- Signer object from ethers library (to use user's wallet).cached
: bool- If the User Proof could be saved to the cache or not.
Return value:
If succeded:
{
signature: "0x00",
walletAddress: "0x00",
}If failed:
ErrorGet an URL of the model
How to import:
import { getParsedURI } from '@style-protocol/sdk'How it looks like:
const getParsedURI = async ({ uri, userProof })uri
: string- model_url from the NFT's metadata.userProof
: Dict- User Proof got using the section above.
Return value:
If succeded:
https://<host>/<signature>/<walletAddress>/<modelName>
OR
ipfs://<ipfsHash> (old ones)If failed:
ErrorLast updated