Script execution failed on commit at Main:25:20: Attempt to fetch or exercise a contract not visible to the reading parties. Contract: #0:0 (UserAdmin:Issuer) actAs: 'Alice' readAs: Disclosed to: 'UserAdmin' Ledger time: 1970-01-01T00:00:00Z
- Nimra_FatimaOP
I got this error in main.daml file on setup script
module Main where import Token import UserAdmin import Daml.Script setup : Script () setup = script do -- user_setup_begin alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice") bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob") charlie <- allocatePartyWithHint "Charlie" (PartyIdHint "Charlie") userAdmin <- allocatePartyWithHint "UserAdmin" (PartyIdHint "UserAdmin") aliceIssuer <- submit userAdmin do createCmd Issuer with userAdmin = userAdmin issuer = alice originalToken <- submit alice do exerciseCmd aliceIssuer MintToken with description = "Cat Pic 1" initialPrice = 100.00 currency = "USD" royaltyRate = 0.05 bobOffer <- submit alice do exerciseCmd originalToken Offer with newOwner = bob price = 200.00 bobRequest <- submit bob do createCmd OwnerRequest with userAdmin = userAdmin owner = bob reason = "I've got connections" bobOwner <- submit userAdmin do exerciseCmd bobRequest GrantOwnerRights charlieRequest <- submit charlie do createCmd OwnerRequest with userAdmin = userAdmin owner = charlie reason = "FOMO" charlieOwner <- submit userAdmin do exerciseCmd charlieRequest GrantOwnerRights (bobToken, _, _) <- submit bob do exerciseCmd bobOwner AcceptTokenAsNewOwner with offerId = bobOffer charlieOffer <- submit bob do exerciseCmd bobToken Offer with newOwner = charlie price = 300.00 submit charlie do exerciseCmd charlieOwner AcceptTokenAsNewOwner with offerId = charlieOffer return () - Gary_Verhaegen
It’s hard to be 100% sure without access to your
Issuertemplate definition, but the error message seems to imply that theIssuercontract you’re creating with:aliceIssuer <- submit userAdmin do createCmd Issuer with userAdmin = userAdmin issuer = aliceis only visible to
UserAdmin, and not toAlice. In order forAliceto be able to do anything with it, you’ll need to add theissuerfield ofIssuerto either thesignatoryor, more likely, theobserverproperty ofIssuer.This is possibly a side-effect of the
controller cantochoicesyntax change: with thecontroller canstyle, the controller is implicitly added toobserver. - Nimra_Fatima
Here is the issuer code
template Issuer with userAdmin: Party issuer: Party where signatory userAdmin nonconsuming choice MintToken: ContractId Token with description: Text initialPrice: Decimal currency: Text royaltyRate: Decimal controller issuer do issued <- getTime create Token with lastPrice = initialPrice owner = issuer .. choice RevokeIssuer: () controller userAdmin do return ()and script error
Script execution failed on commit at Main:25:20: Attempt to fetch or exercise a contract not visible to the reading parties. Contract: #0:0 (UserAdmin:Issuer) actAs: 'Alice' readAs: Disclosed to: 'UserAdmin' Ledger time: 1970-01-01T00:00:00Z Partial transaction: Committed transactions: TX 0 1970-01-01T00:00:00Z (Main:19:18) #0:0 │ known to (since): 'UserAdmin' (0) └─> create UserAdmin:Issuer with userAdmin = 'UserAdmin'; issuer = 'Alice' - Gary_Verhaegen
Right, so this can indeed be fixed by adding
issueras an observer; specifically:module Main where import Daml.Script template Token with lastPrice: Decimal owner: Party where signatory owner template Issuer with userAdmin: Party issuer: Party where signatory userAdmin observer issuer -- This is the line that makes it work nonconsuming choice MintToken: ContractId Token with description: Text initialPrice: Decimal currency: Text royaltyRate: Decimal controller issuer do issued <- getTime create Token with lastPrice = initialPrice owner = issuer .. choice RevokeIssuer: () controller userAdmin do return () setup : Script () setup = script do -- user_setup_begin alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice") bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob") charlie <- allocatePartyWithHint "Charlie" (PartyIdHint "Charlie") userAdmin <- allocatePartyWithHint "UserAdmin" (PartyIdHint "UserAdmin") aliceIssuer <- submit userAdmin do createCmd Issuer with userAdmin = userAdmin issuer = alice originalToken <- submit alice do exerciseCmd aliceIssuer MintToken with description = "Cat Pic 1" initialPrice = 100.00 currency = "USD" royaltyRate = 0.05 pure () - Nimra_Fatima
thanks
@Gary_Verhaegen can you tell me how can I find a DAML developer who can help us in our project as a paid developer… - Navajith_Mohanan
Hi Nimra,
Can you please share your official mail id and accordingly we can connect with you to
discuss regarding the same.Or you can drop a mail to sales@digitalasset.com
Regards,
Nava - Nimra_Fatima
@Navajith_Mohanan
18094198-084@uog.edu.pk
official email id - Nimra_Fatima
@Navajith_Mohanan Hey
I have share my email id and also drop a mail to sales@digitalasset.com
but didn’t get any response yet.I am waiting for your response.
Regards
Nimrah Perveen - Navajith_Mohanan
Hey Nimrah - I have just replied to your email