1

I'm getting this weird error when trying to call the mint entrypoint from another contract... I had additional parameters in the BuyLandRequest and was overriding the TezosHomepageAdNft.mint entrypoint, but even when deleting those parameters and that entrypoint, there is still some incompatibility when making the transfer which is hard to parse out from the error. Any ideas?

Error: Error in Scenario Variant type error in field mint = sp.record(address = sp.address('tz1fDKASJtJHBMM6tXadfZGZhVRSC1igwSSJ'), amount = 1, metadata = {}, token_id = 1) of type sp.TRecord(address = sp.TAddress, amount = sp.TNat, metadata = sp.TMap(sp.TString, sp.TBytes), token_id = sp.TNat).layout((("address", "amount"), ("metadata", "token_id"))) sp.TRecord(address = sp.TAddress, amount = sp.TNat, metadata = sp.TMap(sp.TString, sp.TBytes), token_id = sp.TNat).layout((("address", "amount"), ("metadata", "token_id"))) is not compatible with sp.TUnit in type sp.TVariant(balance_of = sp.TRecord(callback = sp.TContract(sp.TList(sp.TRecord(balance = sp.TNat, request = sp.TRecord(owner = sp.TAddress, token_id = sp.TNat).layout(("owner", "token_id"))).layout(("request", "balance")))), requests = sp.TList(sp.TRecord(owner = sp.TAddress, token_id = sp.TNat).layout(("owner", "token_id")))).layout(("requests", "callback")), mint = sp.TUnit, set_administrator = sp.TAddress, set_metdata = sp.TRecord(k = sp.TString, v = sp.TBytes).layout(("k", "v")), set_pause = sp.TBool, transfer = sp.TList(sp.TRecord(from_ = sp.TAddress, txs = sp.TList(sp.TRecord(amount = sp.TNat, to_ = sp.TAddress, token_id = sp.TNat).layout(("to_", ("token_id", "amount"))))).layout(("from_", "txs"))), update_operators = sp.TList(sp.TVariant(add_operator = sp.TRecord(operator = sp.TAddress, owner = sp.TAddress, token_id = sp.TNat).layout(("owner", ("operator", "token_id"))), remove_operator = sp.TRecord(operator = sp.TAddress, owner = sp.TAddress, token_id = sp.TNat).layout(("owner", ("operator", "token_id")))).layout(("add_operator", "remove_operator")))).layout((("balance_of", ("mint", "set_administrator")), (("set_metdata", "set_pause"), ("transfer", "update_operators"))))

code:

class BuyLandRequest():
    def get_type():
        return sp.TRecord(
            address=sp.TAddress,
            amount=sp.TNat,
            metadata=sp.TMap(sp.TString, sp.TBytes),
            token_id=sp.TNat,)

FA2 = sp.import_script_from_url("https://smartpy.io/dev/templates/FA2.py")
class TezosHomepageAdNft(FA2.FA2):
   @sp.entry_point
    def mint(self, params2):
        sp.set_type_expr(params2, BuyLandRequest.get_type())

class TezosHomepage(sp.Contract):
    def __init__(self, admin, land_nft_address):
        self.init(admin=admin, land_nft_address=land_nft_address)

    @sp.entry_point
    def buy(self, params):
        # create AD NFT here which will be associated with the group of pixels that were purchased
        land_id = sp.len(self.data.lands)
        land_nft_contract = sp.contract(
          BuyLandRequest.get_type(),
          self.data.land_nft_address,
          entry_point = "mint"
        ).open_some(message = "Invalid Interface")
        token_params = sp.record(
            address=sp.sender,
            token_id=1,
            amount=1,
            metadata=sp.map({}),
        )
        sp.transfer(token_params, sp.tez(0), land_nft_contract)

1 Answer 1

1

Replacing sp.set_type_expr(params2, BuyLandRequest.get_type()) with sp.set_type(params2, BuyLandRequest.get_type()) should fix the issue.

Setting a type constraint in SmartPy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.