Here is my Token template in Token.dam
l:
module Token where
{-
• Party can issue tokens
• Party can transfer issued tokens to another Party
-}
type TokenId = ContractId Token
template Token
with
owner: Party
tokenType: Text
value: Int
where
signatory owner
controller owner can
nonconsuming TransferToken: TokenId
with
newOwner : Party
numUnits: Int
do
create Token with
owner = newOwner
value = numUnits
..
And my Main.daml
:
module Main where
import Token
import Daml.Script
setup : Script ()
setup = script do
alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob")
alice_token1_5 <- submit alice do
createCmd Token with
owner = alice
tokenType = "token1"
value = 5
alice_token2_5 <- submit alice do
createCmd Token with
owner = alice
tokenType = "token2"
value = 5
bob_token1_3 <- submit alice do
exerciseCmd alice_token1_5 TransferToken
with
newOwner = bob
numUnits = 3
return ()
I’m getting the error- Scenario execution failed on commit at Main:23:19:
1: create of Token:Token at DA.Internal.Prelude:373:26
failed due to a missing authorization from ‘Bob’
Here is the complete error trace:
Scenario execution failed on commit at Main:23:19:
1: create of Token:Token at DA.Internal.Prelude:373:26
failed due to a missing authorization from 'Bob'
Ledger time: 1970-01-01T00:00:00Z
Partial transaction:
Failed exercise (DA.Internal.Prelude:373:26):
exercise TransferToken on #0:0 (Token:Token)
with
newOwner = 'Bob'; numUnits = 3
Sub-transactions:
1
└─> create Token:Token
with
owner = 'Bob'; tokenType = "token1"; value = 3
Committed transactions:
TX 0 1970-01-01T00:00:00Z (Main:11:21)
#0:0
│ known to (since): 'Alice' (0)
└─> create Token:Token
with
owner = 'Alice'; tokenType = "token1"; value = 5
TX 1 1970-01-01T00:00:00Z (Main:17:21)
#1:0
│ known to (since): 'Alice' (1)
└─> create Token:Token
with
owner = 'Alice'; tokenType = "token2"; value = 5
What is the error & how can I resolve it? I’m new to DAML & will highly appreciate any help on this.