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 ()
It’s hard to be 100% sure without access to your Issuer
template definition, but the error message seems to imply that the Issuer
contract you’re creating with:
aliceIssuer <- submit userAdmin do
createCmd Issuer
with
userAdmin = userAdmin
issuer = alice
is only visible to UserAdmin
, and not to Alice
. In order for Alice
to be able to do anything with it, you’ll need to add the issuer
field of Issuer
to either the signatory
or, more likely, the observer
property of Issuer
.
This is possibly a side-effect of the controller can
to choice
syntax change: with the controller can
style, the controller is implicitly added to observer
.
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'
Right, so this can indeed be fixed by adding issuer
as 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 ()
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…
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
@Navajith_Mohanan
18094198-084@uog.edu.pk
official email id
@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
Hey Nimrah - I have just replied to your email