Hey, so when trying to run a simple tutorial script locally I keep getting this error.
Failed to submit executable script: client: rpc error: code = Internal desc = failed to encode value: unsupported value: <nil>, <nil>
For more context, when using the flow playground I experience no issues with the code. My local machine has the cadence vs code extension installed and flow cli. I used flow init
and flow emulator start
to start the emulator. I am able to run the transaction and get a correct response but it only happens with the script.
import PinataPartyContract from 0xf8d6e0586b0a20c7
pub fun main() : {String : String} {
let nftOwner = getAccount(0xf8d6e0586b0a20c7)
// log("NFT Owner")
let capability = nftOwner.getCapability<&{PinataPartyContract.NFTReceiver}>(/public/NFTReceiver)
let receiverRef = capability.borrow()
?? panic("Could not borrow the receiver reference")
return receiverRef.getMetadata(id: 1)
}
I fairly new to blockchain and flow so I think thereโs probably something simple in the configuration Iโm missing. My guess is the contract isnโt importing correctly, but any help would be greatly appreciated.
I was following the medium article when running into this issue: https://medium.com/pinata/how-to-create-nfts-like-nba-top-shot-with-flow-and-ipfs-701296944bfe
Hi @jmtimper!
I ran into the same problem following that tutorial.
Two changes made the script work for me. Here they areโฆ
Use flow-cli's new script command format
Heads up, be sure youโre running the latest flow-cli (0.16.0). There was a breaking change for script execution in 0.15.0.
The medium tutorial says to run this command:
flow scripts execute ./scripts/CheckTokenMetadata.cdc
However, this is no longer the way. Run this to see the help docs:
flow scripts execute --help
This is the new format:
flow scripts execute --code=scripts/CheckTokenMetadata.cdc
Ensure the token was properly minted
Even using the new script API wonโt work if the token wasnโt properly minted. Iโm not sure what I did wrong, but I kept seeing this in the emulator terminal when running the script:
WARN[0004] ERR [f0fd70] Execution failed:
error: cannot find declaration PinataPartyContract
in `f8d6e0586b0a20c7.PinataPartyContract
To resolve this, I followed these steps:
- Stop and restart the emulator.
- run the deploy command again.
- run the transaction to mint the NFT again
- run the script again
- See the metadata!
A happy log stream in the emulator terminal should look like this:
Best of luck to you as you learn!
I am on version v0.17.0 and I have the same issue. I followed all recommended steps and I am still not able to get rid of this error. Any ideas?
I finally tried this and this fixed my issue:
flow accounts add-contract <name> <filename>