0

I'm in a situation where a user can mint new NFTs of a certain type B only if they are owner of NFT of type A. B NFT checks if caller has A NFT in a mint function. To instantiate a B contract I would need to pass A NFT address in the constructor.

The question is how do I get a hash of freshly created contract in test environment

        fn minting_works() {
            let accounts = default_accounts();

            let mut a_contract= AContract::new();
            set_sender(accounts.alice);

            a_contract.mint(cid.clone()); // Mint A NFT to a user
        

            let mut b_contract= BContract::new(contract_hash);
            b_contract.mint(cid.clone()); // Mint B NFT to a user
        }

2 Answers 2

1

This question has already been asked here. It looks like unfortunately there are at the moment no options to test your smart contract (when cross contract calling) in rust. In the github issue there is a mentoning of redspot, but I don't know how well that would work for you.

0

This answer here also contains more details on cross-contract testing. There are some new features that will be coming out soon to help make this process easier (such as exposing an API to a deployed contract).

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.