1 Star 0 Fork 0

王伟俭 / plugchain-sdk-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
nft.md 6.21 KB
一键复制 编辑 原始数据 按行查看 历史
王伟俭 提交于 2022-04-05 18:20 . 更改依赖项

PLUGCHAIN SDK GO

NFT MODULE

realization

Query

QuerySupply

total supply of a collection or owner of NFTs

res, err := client.Nft.QuerySupply("a123")

QueryOwner

Get the NFTs owned by an account addr.

res, err := client.Nft.QueryOwner("gx1akqhezuftdcc0eqzkq5peqpjlucgmyr7srx54j", "a123", types.PageRequest{
	Offset:     0,
	Limit:      10,
	CountTotal: false,
})

QueryCollection

Get all the NFTs from a given collection.

res, err := client.Nft.QueryCollection("a123", types.PageRequest{
	Offset:     0,
	Limit:      10,
	CountTotal: false,
})

QueryDenom

Query the class by the specified class id.

res, err := client.Nft.QueryDenom("a123")

QueryDenoms

Query all denominations of all collections of NFTs.

res, err := client.Nft.QueryDenoms(types.PageRequest{
	Offset:     0,
	Limit:      10,
	CountTotal: false,
})

QueryNFT

Query a single NFT from a collection

res, err := client.Nft.QueryNFT("a123", "a1232")

TX

IssueDenom

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)

MintNFT

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
}

EditNFT

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)

TransferNFT

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)

TransferClass

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)

BurnNFT

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)
1
https://gitee.com/qizikd/plugchain-sdk-go.git
git@gitee.com:qizikd/plugchain-sdk-go.git
qizikd
plugchain-sdk-go
plugchain-sdk-go
main

搜索帮助