2. Get Data
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
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
Get information on the account by accountName
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))
}
{
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 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);
{
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
}
}
Query the user's asset information
Token
Token ID
BNB
0
LEG
1
REY
2
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))
}
[{"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 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);
[{"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"}]
Query user asset information
Token information
Token
Token ID
BNB
0
LEG
1
REY
2
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))
}
{"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}]}
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);
[{"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}]
Query accountIndex
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)
}
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
Query whether the accountName
has been registered
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))
}
GetAccountIsRegistered: true
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);
GetAccountIsRegistered: true
Get all NFT categories
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))
}
{
"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
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const res = await sdk.getCategories();
console.log(res);
{
"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"
}
]
}
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:
Status
CodeNumber
PENDING
0
CREATED
1
EXPIRED
2
INVALID
10
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 through GetCollectionById
.
pendingCollections
: Collections under the pending status are waiting to be confirmed by Zecrey and cannot be used.
Get collections created by the account name "Alice"
Query the accountIndex
of Alice
Obtain 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))
}
{
"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 collections created by the account name "Alice"
Query the accountIndex
of Alice
Obtain 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);
{
"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 the collection information through collectionID
Get the collection information withcollectionID
=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))
}
{
"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
}
Get the collection information withcollectionID
=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);
{
"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
}
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 the NFTs belonging to this account through the accountIndex
or accountName
The results returned include:
PendingAssets
: 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
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))
}
{
"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 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);
{
"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 the NFT information through NftId
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))
}
{
"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
}
]
}
}
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);
{
"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
}
]
}
}
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:
Status
CodeNumber
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 the offers of this account through accountIndex
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))
}
{
"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
}
......
]
}
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);
{
"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
direction
int
0 BuyNftOffer
, 1 SellNftOffer
Get the offers of this NFT through NftId
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))
}
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 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);
{
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 the information about the offer through OfferId
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))
}
{
"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
}
}
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);
{
"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 the details of the NFT listings and offers and the corresponding NFT information
Field
Category
Field Description
isSell
int64
0 BuyNftOffer
, 1 SellNftOffer
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))
}
{
"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
}
}
}
}
]
}
}
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);
{
"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
}
}
}
}
]
}
}
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