Created
August 29, 2022 09:13
-
-
Save gyorgybalazsi/1fab3792f9fb1bcaac2f04faa781c36f to your computer and use it in GitHub Desktop.
Asset contract and setup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Daml.Script | |
type AssetId = ContractId Asset | |
template Asset | |
with | |
issuer : Party | |
owner : Party | |
name : Text | |
where | |
ensure name /= "" | |
signatory issuer | |
observer owner | |
choice Give : AssetId | |
with | |
newOwner : Party | |
controller owner | |
do create this with | |
owner = newOwner | |
setup : Script AssetId | |
setup = script do | |
-- user_setup_begin | |
alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice") | |
bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob") | |
aliceId <- validateUserId "alice" | |
bobId <- validateUserId "bob" | |
createUser (User aliceId (Some alice)) [CanActAs alice] | |
createUser (User bobId (Some bob)) [CanActAs bob] | |
-- user_setup_end | |
aliceTV <- submit alice do | |
createCmd Asset with | |
issuer = alice | |
owner = alice | |
name = "TV" | |
submit alice do | |
exerciseCmd aliceTV Give with newOwner = bob |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment