I'm trying to create multi-edition items. My idea was to make a list of each token and then each token edition with the owner. Ok, i create the item and shows like that on blockchain: https://api.ghostnet.tzkt.io/v1/contracts/KT1Kzi3GnphcEb2v4WvKxBCFpZZxQD26jerK/bigmaps/data/keys
It shows exactly what i thought, but when i goes to TzKT to see the item, only show 1 created on supply. How can i set this to multi-edition?
The token on TzKT: https://ghostnet.tzkt.io/KT1DSTBaxwdw7tm4MrRwNENpNsKv2bSuQRxX/tokens/0/transfers
What i want: https://tzkt.io/KT1QgfSE4C1dX9UqrPAXjUaFQ36F9eB4nNkV/tokens/18/holders
Also the token metadata if helps: https://api.ghostnet.tzkt.io/v1/contracts/KT1DSTBaxwdw7tm4MrRwNENpNsKv2bSuQRxX/bigmaps/token_metadata/keys
My code:
import smartpy as sp
FA2 = sp.io.import_script_from_url("https://legacy.smartpy.io/templates/fa2_lib.py")
class Token(FA2.Admin, FA2.MintNft, FA2.Fa2Nft):
def __init__(self, admin, **kwargs):
FA2.Fa2Nft.__init__(self, **kwargs)
FA2.Admin.__init__(self, admin)
class Marketplace(sp.Contract):
def __init__(self, token, metadata, admin):
self.init(
token=token,
metadata=metadata,
admin=admin,
data = sp.big_map(
tkey=sp.TNat,
tvalue=sp.TList(
sp.TRecord(
holder=sp.TAddress,
author=sp.TAddress,
amount=sp.TMutez,
token_id=sp.TNat,
editions=sp.TNat,
collectable=sp.TBool))),
token_id=0)
@sp.entry_point
def mint(self, params):
c = sp.contract(
sp.TList(sp.TRecord(to_=sp.TAddress, metadata=sp.TMap(sp.TString, sp.TBytes)).layout(("to_", "metadata"))),
self.data.token,
entry_point="mint").open_some()
args = [sp.record(to_=params.to_, metadata=params.metadata)]
sp.transfer(args, sp.mutez(0), c)
editions_list = sp.local('editions_list', [])
sp.for i in sp.range(1, params.editions + 1):
edition_record = sp.record(
holder=self.data.admin,
author=params.to_,
amount=params.amount,
token_id=self.data.token_id,
editions=i,
collectable=True)
editions_list.value.push(edition_record)
self.data.data[self.data.token_id] = editions_list.value
self.data.token_id += 1
@sp.add_test(name = "Non Fungible Token")
def test():
scenario = sp.test_scenario()
admin = sp.test_account("admin")
mark = sp.test_account("user1")
elon = sp.test_account("user2")
token_contract = Token(
admin=admin.address,
metadata=sp.utils.metadata_of_url(
"ipfs://QmW8jPMdBmFvsSEoLWPPhaozN6jGQFxxkwuMLtVFqEy6Fb"))
scenario += token_contract
scenario.h1("MarketPlace")
marketplace = Marketplace(
token_contract.address,
sp.utils.metadata_of_url(
"ipfs://QmW8jPMdBmFvsSEoLWPPhaozN6jGQFxxkwuMLtVFqEy6Fb"
), admin.address)
scenario += marketplace
token_contract.set_administrator(marketplace.address).run(sender=admin)
marketplace.mint(
to_=admin.address,
amount=sp.tez(100),
editions=sp.nat(5),
metadata={"": sp.pack("ipfs://QmbR82U2yKHbhjve45rqSF9h25s5aFKhMcpZkLRvXRnos6")}
).run(sender=admin)
marketplace.mint(
to_=mark.address,
amount=sp.tez(100),
editions=sp.nat(5),
metadata={"": sp.pack("ipfs://bafyreibwl5hhjgrat5l7cmjlv6ppwghm6ijygpz2xor2r6incfcxnl7y3e/metadata.json")}
).run(sender=admin)
marketplace.mint(to_=mark.address, amount=sp.mutez(5_600_000), editions=5, metadata={"": sp.pack("123423")}).run(sender=admin)