0

I'm building a NFT Marketplace. I already set the mint function (with editions), list and buy function. Now i'm trying to build the auctions functions. On Smartpy, i created the Marketplace class, and now, i set the Auction class, but, if possible, how can i access the contract metadata from the marketplace class? I want to get someinfos from the Marketplace class, like, token_id, editions, owners, etc. On test, i already tried setting Marketplace class on a variable, and then, using it on Auction, but says:

Error: Contracts are not convertible into expressions.



 SmartPy code line 247, in test (line 247)
   auction = Auction(
 SmartPy code line 154, in __init__ (line 154)
   self.init(
 module dc760 line 1373
   setattr(self, k, v)

What i tried is something like this:

scenario.h1("MarketPlace")
marketplace = Marketplace(
    token_contract.address,
    sp.utils.metadata_of_url(
        "ipfs://QmW8jPMdBmFvsSEoLWPPhaozN6jGQFxxkwuMLtVFqEy6Fb"
    ), admin.address)
scenario += marketplace
scenario.h1("Auction")
auction = Auction(
    marketplace,
    admin.address
)
scenario += auction

1 Answer 1

0

In SmartPy, contracts can't be used directly as parameters or accessed by other contracts as simple variables.

For your Auction contract, you can initialize it with the necessary data from the Marketplace's storage like:

auction = Auction(marketplace.data, admin.address)

If the data you're after is subject to change, you might consider having the Auction contract recognize the Marketplace contract's address and make external calls to retrieve data. For this, ensure your Marketplace contract provides on-chain views (special entry points that fetch data without state modifications) to return the needed values.

Your Answer

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

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