The code compiles fine but doesn’t work when I run it. I think I’m missing something obvious but can’t figure out what. The NFT contract I’m trying to call was built using standard templates.
Also, what’s the proper way to make queries or call other entry points from a different contract? Any help would be appreciated.
You’re hitting the message dispatch issue others mentioned, but there’s another gotcha. Your CreateTokenMsg structure might not match what the NFT contract expects - I’ve seen this trip people up when mixing different cw721 implementations. Before diving into debugging, check the NFT contract’s schema file or source code to confirm the exact structure it wants. Some contracts use mint as the message type with different field names, or need additional fields you’re not providing. Debugging trick that saved me time: temporarily add debug prints or events to log the contract address and message before calling wasm_execute. This confirms you’re hitting the right contract with the right data format. For cross-contract queries, use deps.querier.query_wasm_smart(contract_addr, &query_msg) - it’s synchronous and returns the result directly rather than being added to response messages like execute calls.
yeah, sophia’s spot on about the message dispatch issue. double-check your NFT contract actually supports that ExecuteMsg variant - some use Mint instead of CreateToken. i’d log the contract address first to make sure it’s not empty (trips me up all the time). also verify your contract has minting permissions if there are ownership checks.
hmm, looks like you’re missing the actual message dispatch part? when you call wasm_execute() it returns a CosmosMsg but you’re not adding it to your response messages.
you need to add the cosmos message to your response so it gets executed. just creating the message doesn’t automatically send it.
also curious - getting any specific error messages when testing? have you checked if the nft contract address is actually set correctly in your contract state? sometimes it’s just that the target contract isn’t deployed or the address is wrong.
for queries btw, you’d use deps.querier.query_wasm_smart() instead of wasm_execute. what kind of queries are you planning to make to the nft contract?