2. Get Data
Overview
This guide provides information on how to obtain data from the Zecrey NFT Marketplace. In most cases, this data is about the current status of the NFT marketplace (i.e. asset ownership and asset status). Most forms of data available are read-only, so user authentication is not required to update the Zecrey NFT marketplace status. This section describes the method to directly call the SDK package.
Examples of obtained data types commonly include:
Detailed information on assets or a specific asset, including obtaining account information, categories, collections, your own NFTs, tradable offers, etc.
Information of a specific user in the NFT marketplace
Account
Get account details by account name
Get information on the account by
accountName
📚SDK REFERENCE
Example
Get account information with the name "Alice"
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
accountName := "Alice"
accountInfo, err := sdk.GetAccountByAccountName(accountName)
if err != nil { panic(err) }
data, _:= json.Marshal(accountInfo)
fmt.Println(string(data))
}
Example result
{
account:
{
"id":17,
"account_index":14,
"account_name":"Alice",
"bio":"name:Alice age:18 city:New York ",
"email":"aliceaccountemail@gmail.com",
"external_link":"https://alice.xyz",
"twitter_link":"https://twitter.com/alice",
"instagram_link":"https://www.instagram.com/alice/",
"profile_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
"profile_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx.jpg",
"banner_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf.jpg",
"banner_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lo3vtlrcslcr1n7tgiuh.jpg",
"created_at":1667835867
}
}
Example
Get account information with the name "Alice"
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const accountName = "Alice.zec";
const res = await sdk.getAccountByAccountName(accountName);
Example result
{
account:
{
"id":17,
"account_index":14,
"account_name":"Alice",
"bio":"name:Alice age:18 city:New York ",
"email":"aliceaccountemail@gmail.com",
"external_link":"https://alice.xyz",
"twitter_link":"https://twitter.com/alice",
"instagram_link":"https://www.instagram.com/alice/",
"profile_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
"profile_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx.jpg",
"banner_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf.jpg",
"banner_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lo3vtlrcslcr1n7tgiuh.jpg",
"created_at":1667835867
}
}
Get assets by account name
Query the user's asset information
Token
Token ID
BNB
0
LEG
1
REY
2
📚SDK REFERENCE
Example
Get asset information with the name "Alice"
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
accountName := "Alice"
result, err := sdk.GetAccountAssetsInfoByAccountName(accountName)
if err != nil { panic(err) }
data, _ := json.Marshal(accountInfo)
fmt.Println(string(data))
}
Example result
[{"asset_id":0,"balance":"69516961736982000000","lp_amount":"1141481984833460000","offer_canceled_or_finalized":"170141183617213717799641663991588061916"},{"asset_id":1,"balance":"212085509760300000000","lp_amount":"412765957420000000","offer_canceled_or_finalized":"16438259186243607965933629081649153"},{"asset_id":2,"balance":"244530497503355100600","lp_amount":"5180165258600000000","offer_canceled_or_finalized":"0"}]
Example
Get asset information with the name "Alice"
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const account_name = "alice.zec";
const res = await sdk.getAccountAssetsInfoByName(account_name);
console.log(res);
Example result
[{"asset_id":0,"balance":"69516961736982000000","lp_amount":"1141481984833460000","offer_canceled_or_finalized":"170141183617213717799641663991588061916"},{"asset_id":1,"balance":"212085509760300000000","lp_amount":"412765957420000000","offer_canceled_or_finalized":"16438259186243607965933629081649153"},{"asset_id":2,"balance":"244530497503355100600","lp_amount":"5180165258600000000","offer_canceled_or_finalized":"0"}]
Get assets information
Query user asset information
Token information
Token
Token ID
BNB
0
LEG
1
REY
2
📚SDK REFERENCE
Example
Query token information
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
result, err := sdk.GetAssetsList()
if err != nil { panic(err) }
data, _ := json.Marshal(accountInfo)
fmt.Println(string(data))
}
Example result
{"assets":[{"asset_id":0,"asset_name":"BNB","asset_decimals":18,"asset_symbol":"BNB","asset_address":"0x00","is_gas_asset":1},{"asset_id":1,"asset_name":"LEG","asset_decimals":18,"asset_symbol":"LEG","asset_address":"0x364Ed72f329f1BD56AE84b941D1c6E4E260cE152","is_gas_asset":0},{"asset_id":2,"asset_name":"REY","asset_decimals":18,"asset_symbol":"REY","asset_address":"0x9f4c0B11D9cAC63351fd002Cd09812138C6055cb","is_gas_asset":0}]}
Example
Query token information
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const res = await sdk.getSupportedAssets();
console.log(res);
Example result
[{"asset_id":0,"asset_name":"BNB","asset_decimals":18,"asset_symbol":"BNB","asset_address":"0x00","is_gas_asset":1},{"asset_id":1,"asset_name":"LEG","asset_decimals":18,"asset_symbol":"LEG","asset_address":"0x364Ed72f329f1BD56AE84b941D1c6E4E260cE152","is_gas_asset":0},{"asset_id":2,"asset_name":"REY","asset_decimals":18,"asset_symbol":"REY","asset_address":"0x9f4c0B11D9cAC63351fd002Cd09812138C6055cb","is_gas_asset":0}]
Get account index
Query
accountIndex
📚SDK REFERENCE
Example
Query the account index of the name "Alice"
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
accountName := "Alice"
result, err := sdk.GetAccountIndex(accountName)
if err != nil { panic(err) }
data,_:= json.Marshal(result)
fmt.Println("accountIndex:",result.AccountIndex)
}
Example result
accountIndex: 4Example
- Query the account index of the name "Alice"
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const account_name = "Alice.zec";
const res = await sdk.getAccountIndex(account_name);
console.log("accountIndex:", res);
Example result
accountIndex: 4Example
- Query the account index of the name "Alice"
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const account_name = "Alice.zec";
const res = await sdk.getAccountIndex(account_name);
console.log("accountIndex:", res);
Example result
accountIndex: 4
Get account registration status
Query whether the
accountName
has been registered
📚SDK REFERENCE
Example
Query if the account name "Alice" is already registered
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
accountName := "Alice"
result, err := sdk.IfAccountRegistered(accountName)
if err != nil { panic(err) }
data,_:= json.Marshal(result)
fmt.Println("GetAccountIsRegistered:",string(data))
}
Example result
GetAccountIsRegistered: true
Example
Query if the account name "Alice" is already registered
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const account_name = "Alice.zec";
const res = await sdk.ifAccountRegistered(account_name);
console.log("GetAccountIsRegistered:", res);
Example result
GetAccountIsRegistered: true
Category
Get NFT categories
Get all NFT categories
📚SDK REFERENCE
Example
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
result, err := sdk.GetCategories()
if err != nil { panic(err) }
data,_:= json.Marshal(result)
fmt.Println(string(data))
}
Example result
{
"categories":[
{
"id":1,
"name":"Art"
},
{
"id":2,
"name":"Collection"
},
{
"id":3,
"name":"domain name"
},
{
"id":4,
"name":"music"
},
{
"id":5,
"name":"photography"
},
{
"id":6,
"name":"physical education"
},
{
"id":7,
"name":"trading card"
},
{
"id":8,
"name":"Practical"
},
{
"id":9,
"name":"virtual reality"
},
{
"id":10,
"name":"default"
}
]
}on
Example
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const res = await sdk.getCategories();
console.log(res);
Example result
{
"categories":[
{
"id":1,
"name":"Art"
},
{
"id":2,
"name":"Collection"
},
{
"id":3,
"name":"domain name"
},
{
"id":4,
"name":"music"
},
{
"id":5,
"name":"photography"
},
{
"id":6,
"name":"physical education"
},
{
"id":7,
"name":"trading card"
},
{
"id":8,
"name":"Practical"
},
{
"id":9,
"name":"virtual reality"
},
{
"id":10,
"name":"default"
}
]
}
Collections
In the returned details about a collection, there will be a status attribute indicating its
status
(pending, created, expired, invalid, etc.).The
status
of collections can be one of the following:
|
|
PENDING | 0 |
CREATED | 1 |
EXPIRED | 2 |
INVALID | 10 |
Get collections of an account by account index
Get the collections belonging to this account through
accountIndex
The results returned include:
confirmedCollectionIdList
: The collections that have been confirmed by Zecrey and exist in the form of an array id. And the details can be obtained throughGetCollectionById
.pendingCollections
: Collections under the pending status are waiting to be confirmed by Zecrey and cannot be used.
📚SDK REFERENCE
Example
Get collections created by the account name "Alice"
Query the
accountIndex
of AliceObtain the collections created by this account
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
accountName := "Alice"
accountIndex,err:= sdk.GetAccountIndex(accountName)
if err != nil { panic(err) }
result, err := sdk.GetCollectionsByAccountIndex(accountIndex)
if err != nil { panic(err) }
data,_:= json.Marshal(result)
fmt.Println(string(data))
}
Example result
{
"sdkCollections":[
{
"id": 4,
"l2_collection_id":4,
"account_name":"Alice",
"name":"Alice`s space 4",
"short_name":"Alice`s space 4",
"description":"AliceCollection4 description",
"category_id":1,
"collection_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
"external_link":"https://alice.xyz",
"twitter_link":"https://twitter.com/alice",
"instagram_link":"https://www.instagram.com/alice/",
"telegram_link":"https://tgstat.com/channel/@alice",
"discord_link":"https://discord.com/api/v10/applications/<aliceid>/commands",
"logo_image":"https://res.cloudinary.com/zecrey/image/upload/collection/lc02mjan85horu8650td",
"logo_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
"featured_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q",
"featured_Thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx",
"banner_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf",
"banner_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lo3vtlrcslcr1n7tgiuh",
"creator_earning_rate":1000,
"status":"PENDING",
"expired_at":1668083576082,
"created_at":1667910776,
"item_count":3,
"browse_count":6,
"floor_price":2,
"one_day_trade_volume":8.7,
"total_trade_volume":58.7
}
]
}
Example
Get collections created by the account name "Alice"
Query the
accountIndex
of AliceObtain the collections created by this account
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const accountName = "Alice.zec";
const accountIndex = await sdk.getAccountIndex(accountName);
const res = await sdk.getCollectionsByAccountIndex(accountIndex);
console.log(res);
Example result
{
"sdkCollections":[
{
"id": 4,
"l2_collection_id":4,
"account_name":"Alice",
"name":"Alice`s space 4",
"short_name":"Alice`s space 4",
"description":"AliceCollection4 description",
"category_id":1,
"collection_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
"external_link":"https://alice.xyz",
"twitter_link":"https://twitter.com/alice",
"instagram_link":"https://www.instagram.com/alice/",
"telegram_link":"https://tgstat.com/channel/@alice",
"discord_link":"https://discord.com/api/v10/applications/<aliceid>/commands",
"logo_image":"https://res.cloudinary.com/zecrey/image/upload/collection/lc02mjan85horu8650td",
"logo_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
"featured_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q",
"featured_Thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx",
"banner_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf",
"banner_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lo3vtlrcslcr1n7tgiuh",
"creator_earning_rate":1000,
"status":"PENDING",
"expired_at":1668083576082,
"created_at":1667910776,
"item_count":3,
"browse_count":6,
"floor_price":2,
"one_day_trade_volume":8.7,
"total_trade_volume":58.7
}
]
}
Get collection details by ID
Get the collection information through
collectionID
📚SDK REFERENCE
Example
Get the collection information with
collectionID
=3
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
var collectionId int64 = 3
result, err := sdk.GetCollectionById(collectionId)
data,_:= json.Marshal(result)
fmt.Println(string(data))
}
Example result
{
"id": 3,
"l2_collection_id":3,
"account_name":"Alice",
"name":"Alice`s space 3",
"short_name":"Alice`s space 3",
"description":"AliceCollection3 description",
"category_id":1,
"collection_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf.jpg",
"external_link":"https://alice.xyz",
"twitter_link":"https://twitter.com/alice",
"instagram_link":"https://www.instagram.com/alice/",
"telegram_link":"https://tgstat.com/channel/@alice",
"discord_link":"https://discord.com/api/v10/applications/<aliceid>/commands",
"logo_image":"https://res.cloudinary.com/zecrey/image/upload/collection/lc02mjan85horu8650td",
"logo_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
"featured_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q",
"featured_Thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx",
"banner_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf",
"banner_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lo3vtlrcslcr1n7tgiuh",
"creator_earning_rate":0,
"status":"CREATED",
"expired_at":1668083576082,
"created_at":1667910776,
"item_count":3,
"browse_count":6,
"floor_price":2,
"one_day_trade_volume":8.7,
"total_trade_volume":58.7
}
Example
Get the collection information with
collectionID
=3
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const collectionId = 3;
const res = await sdk.getCollectionById(collectionId);
console.log(res);
Example result
{
"id": 3,
"l2_collection_id":3,
"account_name":"Alice",
"name":"Alice`s space 3",
"short_name":"Alice`s space 3",
"description":"AliceCollection3 description",
"category_id":1,
"collection_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf.jpg",
"external_link":"https://alice.xyz",
"twitter_link":"https://twitter.com/alice",
"instagram_link":"https://www.instagram.com/alice/",
"telegram_link":"https://tgstat.com/channel/@alice",
"discord_link":"https://discord.com/api/v10/applications/<aliceid>/commands",
"logo_image":"https://res.cloudinary.com/zecrey/image/upload/collection/lc02mjan85horu8650td",
"logo_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
"featured_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q",
"featured_Thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx",
"banner_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf",
"banner_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lo3vtlrcslcr1n7tgiuh",
"creator_earning_rate":0,
"status":"CREATED",
"expired_at":1668083576082,
"created_at":1667910776,
"item_count":3,
"browse_count":6,
"floor_price":2,
"one_day_trade_volume":8.7,
"total_trade_volume":58.7
}
NFT
In the returned details about an NFT, there will be a status attribute indicating its
status
(pending, created, expired, invalid, etc.).The NFT
status
can be one of the following:Status
CodeNumber
PENDING
0
CREATED
1
EXPIRED
2
INVALID
10
Get NFTs of an account
Get the NFTs belonging to this account through the
accountIndex
oraccountName
The results returned include:
ConfirmedAssetIdList
: NFTs that have been confirmed by Zecrey and exist in the form of an array id. And the specific NFT information can be obtained through Get NFT by IDPendingAssets
: NFTs that are in pending status and waiting to be confirmed by Zecrey, which cannot be used for the following operations:transfer
,withdraw
,listOffer
,makeOffer
📚SDK REFERENCE
Example
Get all the NFT information of one's own account
Get the
accountIndex
Get the NFTs of the
accountIndex
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
accountName := "Alice"
accountIndex,err:=sdk.GetAccountIndex(accountName)//Get the accountIndex of one's own account
if err != nil { panic(err) }
result, err := sdk.GetAccountNFTs(accountIndex)//Get all the NFT information of one's own account
if err != nil { panic(err) }
data,_:= json.Marshal(result)
fmt.Println(string(data))
}
Example result
{
"sdkAssets":[
{
"id":9,
"account_name":"lockkkxj",
"nft_index":4,
"collection_id":21,
"creator_earning_rate":0,
"name":"Pxzkkz01 #2",
"description":"Description information",
"media":"https://res.cloudinary.com/zecrey/image/upload/collection/czpvywx2piq42lauuous",
"image_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/goqywrpyvzjuntaedgas",
"video_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
"audio_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/abf4wd7ults27bqxiciz",
"status":"1",//already created
"content_hash":"faabea2dac2f88a1a87938cdc518f64e2b05dbd5229ca618a9fd579010fff341",
"nft_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf.jpg",
"expired_at":1667964122485,
"created_at":1667877723,
"properties":[
{
"name":"Animal",
"value":"Snow owl"
}
],
"levels":[
{
"name":"Power",
"value":10,
"maxValue":0
}
],
"stats":[
{
"name":"blood",
"value":10,
"maxValue":2
}
]
}
]
}
Example
Get all the NFT information of one's own account
Get the
accountIndex
Get the NFTs of the
accountIndex
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const accountName = "amber1.zec";
const res = await sdk.getAccountIndex(accountName);
console.log(res);
Example result
{
"sdkAssets":[
{
"id":9,
"account_name":"lockkkxj",
"nft_index":4,
"collection_id":21,
"creator_earning_rate":0,
"name":"Pxzkkz01 #2",
"description":"Description information",
"media":"https://res.cloudinary.com/zecrey/image/upload/collection/czpvywx2piq42lauuous",
"image_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/goqywrpyvzjuntaedgas",
"video_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui,
"audio_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/abf4wd7ults27bqxiciz",
"status":"1",//already created
"content_hash":"faabea2dac2f88a1a87938cdc518f64e2b05dbd5229ca618a9fd579010fff341",
"nft_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf.jpg",
"expired_at":1667964122485,
"created_at":1667877723,
"properties":[
{
"name":"Animal",
"value":"Snow owl"
}
],
"levels":[
{
"name":"Power",
"value":10,
"maxValue":0
}
],
"stats":[
{
"name":"blood",
"value":10,
"maxValue":2
}
]
}
]
}
Get NFT details by ID
Get the NFT information through
NftId
📚SDK REFERENCE
Example
Get the NFT information with
NftId
= 14
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
var nftId int64 = 14
result, err := sdk.GetNftById(nftId)
if err != nil { panic(err) }
data, _ := json.Marshal(result)
fmt.Println(string(data))
}
Example result
{
"asset":{
"id":14,
"account_name":"Alice",
"nft_index":14,//nftIndez will be used to interact with l2
"collection_id":3,
"creator_earning_rate":0,
"name":"Alice number 14 nft",
"description":"it·s my number 14 nft",
"media":"https://res.cloudinary.com/zecrey/image/upload/collection/czpvywx2piq42lauuous",
"image_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/czpvywx2piq42lauuous",
"video_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/vo6044kd4qjlgbbeqz0h",
"audio_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/abf4wd7ults27bqxiciz",
"status":"1",//already created
"content_hash":"faabea2dac2f88a1a87938cdc518f64e2b05dbd5229ca618a9fd579010fff341",
"nft_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
"expired_at":1667964122485,
"created_at":1667877723,
"properties":[
{
"name":"Animal",
"value":"Snow owl"
}
],
"levels":[
{
"name":"Power",
"value":10,
"maxValue":0
}
],
"stats":[
{
"name":"blood",
"value":10,
"maxValue":2
}
]
}
}
Example
Get the NFT information with
NftId
= 14
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const nftId = 14;
const res = await sdk.getNftById(nftId);
console.log(res);
Example result
{
"asset":{
"id":14,
"account_name":"Alice",
"nft_index":14,//nftIndex will be used to interact with l2
"collection_id":3,
"creator_earning_rate":0,
"name":"Alice number 14 nft",
"description":"it·s my number 14 nft",
"media":"https://res.cloudinary.com/zecrey/image/upload/collection/czpvywx2piq42lauuous",
"image_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/czpvywx2piq42lauuous",
"video_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/vo6044kd4qjlgbbeqz0h",
"audio_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/abf4wd7ults27bqxiciz",
"status":"1",//already created
"content_hash":"faabea2dac2f88a1a87938cdc518f64e2b05dbd5229ca618a9fd579010fff341",
"nft_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
"expired_at":1667964122485,
"created_at":1667877723,
"properties":[
{
"name":"Animal",
"value":"Snow owl"
}
],
"levels":[
{
"name":"Power",
"value":10,
"maxValue":0
}
],
"stats":[
{
"name":"blood",
"value":10,
"maxValue":2
}
]
}
}
Offers
In the returned details about an offer, there will be a status attribute indicating its
status
(pending, created, expired, invalid, etc.).The offer
status
can be one of the following:
|
|
Pending | 0 |
Offer Created | 1 |
matchOffer to be Verified on L2 | 2 |
matchOffer Verified on L2 | 3 |
Offer Canceled | 4 |
Expired | 6 |
Invalid | 10 |
Get offers of an account
Get the offers of this account through
accountIndex
📚SDK REFERENCE
Example
Get the offers of this account
Get
accountIndex
Get the offers of this account
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
accountName := "Alice"
accountIndex,err:= sdk.GetAccountIndex(accountName)
if err != nil { panic(err) }
result, err := sdk.GetAccountOffers(accountIndex)
if err != nil { panic(err) }
data, _ := json.Marshal(result)
fmt.Println(string(data))
}
Example result
{
"sdkOffers":[
{
"id":15,
"account_name":"Alice",
"asset_id":14,
"created_at":1584313213,
"direction":1,
"expired_at":76434131354,
"payment_asset_amount":100000,
"payment_asset_id":0,
"signature":{
"Type":1,
"OfferId":1,
"AccountIndex":4,
"NftIndex":4,
"AssetId":0,
"AssetAmount":1000000000000000000,
"ListedAt":1667875812560,
"ExpiredAt":1668307810076,
"TreasuryRate":30,
"Sig":"0tFMdyguNXx6mJEtM3CL8OK62M4vmQqzVpre4zLuRgwFb0bR2IOs0v/A2ZsKhSRvKtJhs9yhz008Yz2akYAczQ=="
},
"status":2 //The offer has been matExample
- Get the offers of this account
1. Get accountIndex
2. Get the offers of this account
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const accountName = "Alice.zec";
const accountIndex = await sdk.getAccountIndex(accountName);
const res = await sdk.getAccountOffers(accountIndex);
console.log(res);
Example result
{
"sdkOffers":[
{
"id":15,
"account_name":"Alice",
"asset_id":14,
"created_at":1584313213,
"direction":1,
"expired_at":76434131354,
"payment_asset_amount":100000,
"payment_asset_id":0,
"signature":{
"Type":1,
"OfferId":1,
"AccountIndex":4,
"NftIndex":4,
"AssetId":0,
"AssetAmount":1000000000000000000,
"ListedAt":1667875812560,
"ExpiredAt":1668307810076,
"TreasuryRate":30,
"Sig":"0tFMdyguNXx6mJEtM3CL8OK62M4vmQqzVpre4zLuRgwFb0bR2IOs0v/A2ZsKhSRvKtJhs9yhz008Yz2akYAczQ=="
},
"status":2 //The offer has been matched and is waiting to be verified on L2
}
......
]
}ched and is waiting to be verified on L2
}
......
]
}
Example
Get the offers of this account
Get
accountIndex
Get the offers of this account
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const accountName = "Alice.zec";
const accountIndex = await sdk.getAccountIndex(accountName);
const res = await sdk.getAccountOffers(accountIndex);
console.log(res);
Example result
{
"sdkOffers":[
{
"id":15,
"account_name":"Alice",
"asset_id":14,
"created_at":1584313213,
"direction":1,
"expired_at":76434131354,
"payment_asset_amount":100000,
"payment_asset_id":0,
"signature":{
"Type":1,
"OfferId":1,
"AccountIndex":4,
"NftIndex":4,
"AssetId":0,
"AssetAmount":1000000000000000000,
"ListedAt":1667875812560,
"ExpiredAt":1668307810076,
"TreasuryRate":30,
"Sig":"0tFMdyguNXx6mJEtM3CL8OK62M4vmQqzVpre4zLuRgwFb0bR2IOs0v/A2ZsKhSRvKtJhs9yhz008Yz2akYAczQ=="
},
"status":2 //The offer has been matched and is waiting to be verified on L2
}
......
]
}
Note: The direction field in the offer information can help identify whether this offer is a buy
(0) or a sell
(1).
Field | Category | Field Description |
|
| 0 |
Get NFT Offers
Get the offers of this NFT through
NftId
📚SDK REFERENCE
Example
Get the offers of the account with
NftId
= 14
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
nftId:= 14
result, err := sdk.GetNftOffers(nftId)
if err != nil { panic(err) }
data, _ := json.Marshal(result)
fmt.Println(string(data))
}
Example result
sdkAssets: [{
id:4
account_name:"Alice"
asset_id:147
created_at:1584313213
direction:1
expired_at:76434131354
payment_asset_amount:100000
payment_asset_id:0
signature:{"Type":1,"OfferId":1,"AccountIndex":4,"NftIndex":2,"AssetId":0,"AssetAmount":3000000000000000000,"ListedAt":1667875812560,"ExpiredAt":1668307810076,"TreasuryRate":30,"Sig":"0tFMdyguNXx6mJEtM3CL8OK62M4vmQqzVpre4zLuRgwFb0bR2IOs0v/A2ZsKhSRvKtJhs9yhz008Yz2akYAczQ=="}
status:3
}
.....]
Example
Get the offers of the account with
NftId
= 14
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const nftId = 14;
const res = await sdk.getNftOffers(nftId);
console.log(res);
Example result
{
sdkAssets: [{
id:4
account_name:"Alice"
asset_id:147
created_at:1584313213
direction:1
expired_at:76434131354
payment_asset_amount:100000
payment_asset_id:0
signature:{"Type":1,"OfferId":1,"AccountIndex":4,"NftIndex":2,"AssetId":0,"AssetAmount":3000000000000000000,"ListedAt":1667875812560,"ExpiredAt":1668307810076,"TreasuryRate":30,"Sig":"0tFMdyguNXx6mJEtM3CL8OK62M4vmQqzVpre4zLuRgwFb0bR2IOs0v/A2ZsKhSRvKtJhs9yhz008Yz2akYAczQ=="}
status:3
}
.....]
}
Get offer details by ID
Get the information about the offer through
OfferId
📚SDK REFERENCE
Example
Get the offer information with
OfferId
= 5
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
offerId:= 5
result, err := sdk.GetOfferById(OfferId)
if err != nil { panic(err) }
data, _ := json.Marshal(result)
fmt.Println( string(data))
}
Example result
{
"offer":{
"id":5,
"account_name":"amber1",
"direction":"1",//1:sell 0:buy
"asset_id":7,
"payment_asset_id":0,
"payment_asset_amount":"3.000000000000000000",//sell at 3 BNB
"status":"1",// successfully created
"signature":"{\"Type\":1,\"OfferId\":1,\"AccountIndex\":4,\"NftIndex\":2,\"AssetId\":0,\"AssetAmount\":3000000000000000000,\"ListedAt\":1667875812560,\"ExpiredAt\":1668307810076,\"TreasuryRate\":30,\"Sig\":\"0tFMdyguNXx6mJEtM3CL8OK62M4vmQqzVpre4zLuRgwFb0bR2IOs0v/A2ZsKhSRvKtJhs9yhz008Yz2akYAczQ==\"}",
"expired_at":1668307810076,
"created_at":1667875810
}
}
Example
Get the offer information with
OfferId
= 5
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const offerId = 5;
const res = await sdk.getOfferById(offerId);
console.log(res);
Example result
{
"offer":{
"id":5,
"account_name":"amber1",
"direction":"1",//1:sell 0:buy
"asset_id":7,
"payment_asset_id":0,
"payment_asset_amount":"3.000000000000000000",//sell at 3 BNB
"status":"1",// successfully created
"signature":"{\"Type\":1,\"OfferId\":1,\"AccountIndex\":4,\"NftIndex\":2,\"AssetId\":0,\"AssetAmount\":3000000000000000000,\"ListedAt\":1667875812560,\"ExpiredAt\":1668307810076,\"TreasuryRate\":30,\"Sig\":\"0tFMdyguNXx6mJEtM3CL8OK62M4vmQqzVpre4zLuRgwFb0bR2IOs0v/A2ZsKhSRvKtJhs9yhz008Yz2akYAczQ==\"}",
"expired_at":1668307810076,
"created_at":1667875810
}
}json
Get details about NFT listings and offers
Get the details of the NFT listings and offers and the corresponding NFT information
Field | Category | Field Description |
|
| 0 |
📚SDK REFERENCE
Example
Get details of the listing and the corresponding NFT information
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
var offerType int64 = 1
result, err := sdk.GetListingOffers(offerType)
if err != nil { panic(err) }
data, _ := json.Marshal(result)
fmt.Println(string(data))
}
Example result
{
"data":{
"offer":[
{
{
"id":53,
"l2_offer_id":18,
"direction":1,
"asset_id":19,
"payment_asset_id":0,
"payment_asset_amount":100,
"status":1,
"signature":"{\"Type\":1,\"OfferId\":18,\"AccountIndex\":18,\"NftIndex\":19,\"AssetId\":0,\"AssetAmount\":100000000000000000000,\"ListedAt\":1668175126138,\"ExpiredAt\":1668607122441,\"TreasuryRate\":30,\"Sig\":\"mYlFH0uvCiipd2bfGHbxgHWUvzbDuNUKTskXbgaATI4FmJxmnSFwA2MzU5cVtcxJn/vh11D8p9n+qCr6nE9cEA==\"}",
"expired_at":1668607122441,
"created_at":"2022-11-11T13:58:45.799273+00:00",
"asset":{
"id":19,
"nft_index":19,
"collection_id":22,
"creator_earning_rate":0,
"name":"ooo #1",
"description":"ooooo",
"media_detail":{
"url":"https://res.cloudinary.com/zecrey/image/upload/v1668066577/collection/een1olis8b2jofcx4pew.jpg"
},
"image_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lc02mjan85horu8650td",
"video_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf",
"audio_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx",
"status":1,
"content_hash":"1f06251dc934955c23173cc2a28536319cda2986f675f41bd48f1b1647bc718f",
"nft_url":"-",
"expired_at":1668152992703,
"created_at":0,
"properties":{
"name":"assetProperty",
"value":"red"
},
"levels":{
"name":"assetLevel",
"value":120,
"maxValue":100
},
"stats":{
"name":"StatType",
"value":400,
"maxValue":200
}
}
}
}
]
}
}
Example
Get details of a listing and the corresponding NFT information
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const offerType = 1;
const res = await sdk.getListingOffers(offerType);
console.log(res);
Example result
{
"data":{
"offer":[
{
{
"id":53,
"l2_offer_id":18,
"direction":1,
"asset_id":19,
"payment_asset_id":0,
"payment_asset_amount":100,
"status":1,
"signature":"{\"Type\":1,\"OfferId\":18,\"AccountIndex\":18,\"NftIndex\":19,\"AssetId\":0,\"AssetAmount\":100000000000000000000,\"ListedAt\":1668175126138,\"ExpiredAt\":1668607122441,\"TreasuryRate\":30,\"Sig\":\"mYlFH0uvCiipd2bfGHbxgHWUvzbDuNUKTskXbgaATI4FmJxmnSFwA2MzU5cVtcxJn/vh11D8p9n+qCr6nE9cEA==\"}",
"expired_at":1668607122441,
"created_at":"2022-11-11T13:58:45.799273+00:00",
"asset":{
"id":19,
"nft_index":19,
"collection_id":22,
"creator_earning_rate":0,
"name":"ooo #1",
"description":"ooooo",
"media_detail":{
"url":"https://res.cloudinary.com/zecrey/image/upload/v1668066577/collection/een1olis8b2jofcx4pew.jpg"
},
"image_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lc02mjan85horu8650td",
"video_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf",
"audio_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx",
"status":1,
"content_hash":"1f06251dc934955c23173cc2a28536319cda2986f675f41bd48f1b1647bc718f",
"nft_url":"-",
"expired_at":1668152992703,
"created_at":0,
"properties":{
"name":"assetProperty",
"value":"red"
},
"levels":{
"name":"assetLevel",
"value":120,
"maxValue":100
},
"stats":{
"name":"StatType",
"value":400,
"maxValue":200
}
}
}
}
]
}
}
Last updated