Zecrey
Search
K

5. Mint Assets

Register users

  • Before users can mint/collect assets and create projects on Zecrey, they must register as Zecrey users. Please follow this procedure.
  • Zecrey NFT Marketplace has set several default categories to divide the collections. When creating a collection, you must select between one of the categories.

Upload Media

  • Upload pictures
📚SDK REFERENCE
Golang
Javascript
Example
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
filePath := "/Users/alice/Documents/20221112-142909.jpg"
result, err := sdk.UploadMedia(filePath)
if err != nil { panic(err) }
data, _ := json.Marshal(result)
fmt.Println(string(data))
}
Example result
{
"public_id":"collection/tsgqu4cgj57wrxncllky", //unique Id of the picture
"url":"https://res.cloudinary.com/zecrey/image/upload/v1668506730/collection/tsgqu4cgj57wrxncllky.jpg" //link of the picture
}
Example
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const url = "/Users/alice/Documents/20221112-142909.jpg";
const blob = await (await fetch(url)).blob();
const media = new File([blob], "media");
const res = await sdk.uploadMedia(media);
console.log(res);
Example result
{
"public_id":"collection/tsgqu4cgj57wrxncllky", //unique Id of the picture
"url":"https://res.cloudinary.com/zecrey/image/upload/v1668506730/collection/tsgqu4cgj57wrxncllky.jpg" //link of the picture
}

Create a Collection

  • When minting an NFT, it will be identified in a collection to distinguish different styles or topics. Collections will be submitted to the L1 chain by Zecrey. All collections created through Zecrey will be searchable in the NFT Marketplace.
  • The transaction of creating a collection will be confirmed by Zecrey. Once Zecrey confirms this collection, it will be submitted to L1.
  • Parameters needed for creating a collection:
Parameter
Parameter usage and meaning
Required vs Optional
accountName
The account name used to initialize the client
seed
The user's L2 seed used to initialize the client
ShortName
Used to create and identify a collection; cannot be duplicated with other collections
CategoryId
Used to create a collection
CollectionUrl
The background image displayed for mobile users
ExternalLink
External link to the collection
TwitterLink
Twitter link to the collection
InstagramLink
Instagram link to the collection
TelegramLink
Telegram link to the collection
DiscordLink
Discord link of the collection
LogoImage
The logo image id of the collection
FeaturedImage
The feature image id of the collection
BannerImage
The Banner image id of the collection
Description
The description of the collection, and filling in "-" is recommended if there is no description
CreatorEarningRate
Creator royalities
PaymentAssetIds
Asset types used to settle

📚SDK REFERENCE

Golang
Javasript
Example
  • Create a collection with the ShortName "Alice's space"
    1. 1.
      Initialize the client
    2. 2.
      Create a collection
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk/model"
)
func main() {
accountName := "Alice"
seed := "0x6a1a320d14790f2d9aa9a37769f4833d583a3f7f974fd452a3990aeb0e7a6052"
ShortName := "Alice`s space"
CategoryId := "1"
CollectionUrl := "https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg"
ExternalLink := "https://weibo.com/alice"
TwitterLink := "https://twitter.com/alice"
InstagramLink := "https://www.instagram.com/alice/"
TelegramLink := "https://tgstat.com/channel/@alice"
DiscordLink := "https://discord.com/api/v10/applications/<aliceid>/commands"
LogoImage := "collection/lc02mjan85horu8650td" //unique id after uploading images
FeaturedImage := "collection/ahykviwc0suhoyzusb5q"//unique id after uploading images
BannerImage := "collection/lo3vtlrcslcr1n7tgiuh"//unique id after uploading images
Description := "Description information"//description of the collection
CreatorEarningRate := "0"//reserved field with no substance
PaymentAssetIds := "[]"
c, err := sdk.NewClient(accountName, seed)
if err != nil { panic(err) }
result, err := c.CreateCollection(ShortName, CategoryId, CreatorEarningRate,
model.WithCollectionUrl(CollectionUrl),//variable parameter which is optional
model.WithExternalLink(ExternalLink),
model.WithTwitterLink(TwitterLink),
model.WithInstagramLink(InstagramLink),
model.WithTelegramLink(TelegramLink),
model.WithDiscordLink(DiscordLink),
model.WithLogoImage(LogoImage),
model.WithFeaturedImage(FeaturedImage),
model.WithBannerImage(BannerImage),
model.WithDescription(Description),
model.WithPaymentAssetIds(PaymentAssetIds))
if err != nil { panic(err) }
data, err := json.Marshal(result)
if err != nil { panic(err) }
fmt.Println(string(data))
}
Example result
{
"collection":{
"id":22,
"l2_collection_id":1,
"account_name":"Alice",
"name":"collection_Shortname 55",
"short_name":"collection_Shortname 55",//unique short_name for the collection
"description":"Description information",
"category_id":1,
"collection_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
"external_link":"https://weibo.com/alice",
"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,//reserved field with no substance
"status":"PENDING",
"expired_at":1668083576082,
"created_at":1667910776,
"item_count":3,
"browse_count":0,
"floor_price":2,
"one_day_trade_volume":8.7,
"total_trade_volume":58.7
}
}
Example
  • Create a collection with the ShortName "Alice's space"
    1. 1.
      Initialize the client
    2. 2.
      Create a collection
With the private key:
import { Client } from "@zecrey/zecrey-legend-js-sdk";
const account_name = "Alice.zec";
const seed = "0x6a1a320d14790f2d9aa9a37769f4833d583a3f7f974fd452a3990aeb0e7a6052";
const client = new Client(account_name, seed);
await client.initialize();
const category_id = 2;
const logo_image = "collection/in9tbyo5gheczolvhezx";
const description = "Description information";
const banner_image = "collection/pj4u3xm2j4jzeqcvogfd";
const shortname = "Alice's space";
const creator_earning_rate = 0.02; // 2%
const featured_image = "";
const collection_url = "";
const external_link = "";
const twitter_link = "";
const instagram_link = "";
const discord_link = "";
const telegram_link = "";
const res = await client.createCollection(category_id, logo_image, description, banner_image, shortname, creator_earning_rate, featured_image, collection_url, external_link, twitter_link, instagram_link, discord_link, telegram_link);
console.log("collection id: ", res);
With the wallet:
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const account_name = "Alice.zec"; // sender's account name
const account_index = 14; // sender's account index
const category_id = 2;
const logo_image = "collection/in9tbyo5gheczolvhezx";
const description = "Description information";
const banner_image = "collection/pj4u3xm2j4jzeqcvogfd";
const shortname = "Alice's space";
const creator_earning_rate = 0.02; // 2%
const featured_image = "";
const collection_url = "";
const external_link = "";
const twitter_link = "";
const instagram_link = "";
const discord_link = "";
const telegram_link = "";
const res = await sdk.createCollection(account_name, account_index, category_id, logo_image, description, banner_image, shortname, creator_earning_rate, featured_image, collection_url, external_link, twitter_link, instagram_link, discord_link, telegram_link);
console.log("collection id: ", res);
Example result
collection id: 45971j

Mint NFT

  • Every account has a default collection ID. If the collection ID is not filled in, the NFT will be associated with the default collection ID = 0. Transaction of minting an NFT will be confirmed by Zecrey and once the NFT is confirmed, Zecrey will submit it to L1.
  • L2 allows the change of ownership for the NFT. However, the creator of the NFT will never change. Each time an NFT is transferred, the creator will receive a royalty, which is calculated by the NFT's TreasuryRate set by its creator.

📚SDK REFERENCE

  • Parameters needed for creating an NFT:
    Parameter
    Parameter usage and meaning
    Required or not
    accountName
    The account name used to initialize the client
    seed
    The user's L2 seed used to initialize the client
    NftUrl
    The logo image displayed for mobile users
    Name
    NFT name
    Description
    The description of the NFT, and filling in "-" is recommended if there is no description
    assetProperty
    Custom properties
    assetLevel
    Custom levels
    assetStats
    Custom stats
    TreasuryRate
    Creator royalties will be charged at this rate and the percentage will be in proportion to 10000 during NFT transactions. For example, filling in 50000 means the rate will be 5000/10000 % = 0.5%
  • Create an NFT with the name "Alice's BestNft"
    1. 1.
      Initialize the client
    2. 2.
      Use json Marshal to transform the properties, levels and stats into string type
    3. 3.
      Create an NFT
Golang
Javascript
Example
package main
import (
"fmt"
"github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)
func main() {
var CollectionId int64 = 15 //Get list of collections
accountName := "Alice"
seed := "0x6a1a320d14790f2d9aa9a37769f4833d583a3f7f974fd452a3990aeb0e7a6052"
c, err := sdk.NewClient(accountName, seed)
if err != nil { panic(err) }
NftUrl := "https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg"
Name := "Alice`s BestNft"
Description := "my first nft"
Media := "collection/dekkg5j1ptccq9ttliui"//public Id after uploading media
TreasuryRate:=10
assetProperty := Propertie{ //custom properties
Name: "assetProperty",
Value: "red1",
}
assetLevel := Level{ //custom levels
Name: "assetLevel",
Value: 120,
MaxValue: 100,
}
assetStats := Stat{//custom stats
Name: "StatType",
Value: 400,
MaxValue: 200,
}
// get content hash
_Properties := []Propertie{assetProperty}
_Levels := []Level{assetLevel}
_Stats := []Stat{assetStats}
_PropertiesByte, err := json.Marshal(_Properties)
_LevelsByte, err := json.Marshal(_Levels)
_StatsByte, err := json.Marshal(_Stats)
result, err := c.MintNft(
CollectionId,
NftUrl, Name,
TreasuryRate,
Description, Media,
string(_PropertiesByte), string(_LevelsByte), string(_StatsByte))
if err != nil { panic(err) }
data, err := json.Marshal(result)
if err != nil { panic(err) }
fmt.Println(string(data))
}
Example result
{
"asset":{
"id":11,
"account_name":"Alice.zec",
"nft_index":-1,//nftindex = -1 means that the NFT is in pending state and operations like transfer cannot be done with this NFT
"collection_id":15,
"creator_earning_rate":0,
"name":"Alice`s BestNft",
"description":"my first nft",
"media":"collection/dekkg5j1ptccq9ttliui",
"image_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
"video_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
"audio_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
"status":"0",
"content_hash":"6a7ab257b1f42474d31b2b94b483d2b34702e8d89fa21481574232cd979bdfe3", //ACC:Alice.zec CID:15 NFT:- PROPERTIES: k:assetProperty v:red1 LEVELS: k:assetLevel v:123 STATS: k:StatType v:456 Calculate the hash of the account name, collectionid, shortName, assetProperty, assetLevel, assetStats to get the value
"nft_url":"-",
"expired_at":1668085431849,
"created_at":1667912632,
"properties":[
{
"name":"assetProperty",
"value":"red1"
}
],
"levels":[
{
"name":"assetLevel",
"value":120,
"maxValue":100
}
],
"stats":[
{
"name":"StatType",
"value":400,
"maxValue":200
}
]
}
}
Example
With the private key:
import { Client } from "@zecrey/zecrey-legend-js-sdk";
const account_name = "Alice.zec";
const seed = "0x6a1a320d14790f2d9aa9a37769f4833d583a3f7f974fd452a3990aeb0e7a6052";
const client = new Client(account_name, seed);
await client.initialize();
const collection_id = 5;
const nft_url = "";
const name = "amber's nft";
const description = "Description information";
const media = "collection/in9tbyo5gheczolvhezx";
const properties = "[{"name":"color","value":"black"}]";
const levels = "[]";
const stats = "[]";
const res = await client.mintNft(collection_id, nft_url, name, description, media, properties, levels, stats);
console.log("NFT id: ", res);
With the wallet:
import { SDK } from "@zecrey/zecrey-legend-js-sdk";
const sdk = new SDK();
await sdk.initial();
const account_name = "Alice.zec"; // sender's account name
const account_index = 14; // sender's account index
const collection_id = 5;
const nft_url = "";
const name = "amber's nft";
const description = "Description information";
const media = "collection/in9tbyo5gheczolvhezx";
const properties = "[{"name":"color","value":"black"}]";
const levels = "[]";
const stats = "[]";
const res = await sdk.mintNft(account_name, account_index, collection_id, nft_url, name, description, media, properties, levels, stats);
console.log("NFT id: ", res);
Example result
NFT id: 78981