Script throws variable not in scope
- suchindraOP 2
I am learning DAML. While following the tutorial at the following location, I am shown an error saying :
/home/suchivaish/src/Office/DAML/Token.daml:22:16: error: Variable not in scope: script : Scenario (ContractId Token) -> ttypecheckTutorial link: https://docs.daml.com/daml/intro/2_DamlScript.html
My Token.daml file:
module Token where template Token with owner : Party where signatory owner -- The below code works: -- token_test_1 = do -- alice <- getParty "Alice" -- submit alice do -- create Token with owner = alice token_test_2 = script do bob <- getParty "Bob" submit bob do create Token with owner = bobRequest you to please help me with what is wrong with the above code
- Gary_Verhaegen 2
Hi @suchindra,
The
scriptfunction is not part of the core DAML language; it is part of a separate module in the standard library. To get access to it, you have to explicitly important that module. The easiest way to do that is to add this line:import Daml.Scriptright after the
module ... whereline, near the top of the file. - suchindra 2
Thanks @Gary_Verhaegen

Including the import statement enabled the script module to be downloaded. The only additional thing I had to do was
- Create a daml.yaml file with the following:
sdk-version: 1.6.1 name: szabo_car_contract version: 1.0.0 source: daml/Token.daml scenario: Token parties: - Alice - Bob exposed-modules: - Main dependencies: - daml-prim - daml-stdlib - daml-script- And restart the visual studio