total supply of a collection or owner of NFTs
res, err := client.Nft.QuerySupply("a123")
Get the NFTs owned by an account addr.
res, err := client.Nft.QueryOwner("gx1akqhezuftdcc0eqzkq5peqpjlucgmyr7srx54j", "a123", types.PageRequest{
Offset: 0,
Limit: 10,
CountTotal: false,
})
Get all the NFTs from a given collection.
res, err := client.Nft.QueryCollection("a123", types.PageRequest{
Offset: 0,
Limit: 10,
CountTotal: false,
})
Query the class by the specified class id.
res, err := client.Nft.QueryDenom("a123")
Query all denominations of all collections of NFTs.
res, err := client.Nft.QueryDenoms(types.PageRequest{
Offset: 0,
Limit: 10,
CountTotal: false,
})
Query a single NFT from a collection
res, err := client.Nft.QueryNFT("a123", "a1232")
Issue a new class. You need to import the private key before you can operate,Please see the key package for importing the private key
baseTx := types.BaseTx{
From: "demo", //Account name
Password: "123123123",
Gas: 200000,
Mode: types.Commit,
Memo: "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000uplugcn") //Fee
request := nft.IssueDenomRequest{
ID: "a123",//The name of the collection
Name: "aad",//The name of the class
Schema: "test",
Symbol: "aads",
MintRestricted: false,//MintRestricted is true means that only class owners can issue NFTs under this category, false means anyone can
EditRestricted: false,//EditRestricted is true means that no one in this category can edit the NFT, false means that only the owner of this NFT can edit
}
res, err := client.Nft.IssueDenom(request, baseTx)
Issue a new nft. You need to import the private key before you can operate,Please see the key package for importing the private key
baseTx := types.BaseTx{
From: "demo", //Account name
Password: "123123123",
Gas: 200000,
Mode: types.Commit,
Memo: "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000uplugcn") //Fee
request := nft.MintNFTRequest{
ID: "a1231",//The id of the nft
ClassID: "a123",//The name of the collection
Name: "aad",//The name of nft
URI: "https://www.baidu.com",//URI of off-chain NFT data
Data: string(getArmor()),//The data of the nft data
Recipient: "",
}
res, err := client.Nft.MintNFT(request, baseTx)
func getArmor() []byte {
path, err := os.Getwd()
if err != nil {
panic(err)
}
path = filepath.Dir(path)
path = filepath.Join(path, "gitee.com/qizikd/plugchain-sdk-go/test/aad.info")
bz, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
return bz
}
edit a nft. You need to import the private key before you can operate,Please see the key package for importing the private key
baseTx := types.BaseTx{
From: "demo", //Account name
Password: "123123123",
Gas: 200000,
Mode: types.Commit,
Memo: "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000uplugcn") //Fee
request := nft.EditNFTRequest{
ID: "a1231",//The id of the nft
ClassID: "a123",//The name of the collection
Name: "aads",
URI: "https://www.google.com",
Data: "this is a tree",
}
res, err := client.Nft.EditNFT(request, baseTx)
transfer an NFT to a recipient. You need to import the private key before you can operate,Please see the key package for importing the private key
baseTx := types.BaseTx{
From: "demo", //Account name
Password: "123123123",
Gas: 200000,
Mode: types.Commit,
Memo: "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000uplugcn") //Fee
request := nft.TransferNFTRequest{
ID: "a1231",//The id of the nft
ClassID: "a123",//The name of the collection
Recipient: "gx1akqhezuftdcc0eqzkq5peqpjlucgmyr7srx54j",
}
res, err := client.Nft.TransferNFT(request, baseTx)
transfer an Class to a recipient. You need to import the private key before you can operate,Please see the key package for importing the private key
baseTx := types.BaseTx{
From: "demo", //Account name
Password: "123123123",
Gas: 200000,
Mode: types.Commit,
Memo: "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000uplugcn") //Fee
request := nft.TransferClassRequest{
ID: "a123",//The name of the collection
Recipient: "gx1akqhezuftdcc0eqzkq5peqpjlucgmyr7srx54j",
}
res, err := client.Nft.TransferClass(request, baseTx)
burn a nft. You need to import the private key before you can operate,Please see the key package for importing the private key
baseTx := types.BaseTx{
From: "demo", //Account name
Password: "123123123",
Gas: 200000,
Mode: types.Commit,
Memo: "test",
}
baseTx.Fee, err = types.ParseDecCoins("2000uplugcn") //Fee
request := nft.BurnNFTRequest{
ID: "a1231",//The id of the nft
ClassID: "a123",//The name of the collection
}
res, err := client.Nft.BurnNFT(request, baseTx)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。