: Script ()
Defined at /Users/kr.aalle/Desktop/new_nft/nft/daml/Main.daml:9:1
Script execution failed on commit at Main:21:20:
Attempt to fetch or exercise a contract not visible to the reading parties.
Contract: #0:0 (UserAdmin:Issuer)
Disclosed to: 'UserAdmin'
Ledger time: 1970-01-01T00:00:00Z
TX 0 1970-01-01T00:00:00Z (Main:15:18)
│ disclosed to (since): 'UserAdmin' (0)
└─> create UserAdmin:Issuer
userAdmin = 'UserAdmin'; issuer = 'Alice'Script
All contracts used in a Daml transaction must be visible to the submitter or more precisely the union of actAs and readAs parties. In your example it looks like the Issuer contract is only visible to userAdmin (probably they are the only signatory and there are no observers?) but you’re trying to use it in a submission which only has alice as the reading party.
There are two ways to fix this:
Make alice an observer on the contract by adding the issuer of the Issuer template as an observer.
Add the userAdmin as a readAs party so switch to submitMulti [alice] [userAdmin]. While this is convenient in tests, in a real system getting the authority from the userAdmin to let Alice see all of their contracts can be tricky.
Based on the information you shared 1 seems like the best option.
Could you point me to the video and the source code you used? The reason I ask is that, as far as I can see, the code in Introduction to Daml video tutorial series available from this link and in the Github repo, which those series reference, uses deprecated but still supported “controller … can” syntax in choices, which implicitly adds choice controller as an observer on the template. Thus, if you use the templates code from the videos or from the referenced Github repo, you shouldn’t get the error in the Daml Script that you experienced. I would expect to see this error only if you updated the templates by replacing the deprecated “controller … can” syntax with the “choice …” syntax. And if that’s what you did, then, as @cocreature advised, the fix is to explicitly add the choice controller as an observer on the template (unless the controller is a signatory).
Does this make sense? Please, let me know if you need additional help.