1
1
import " ExampleToken"
2
2
3
- // This transaction mints tokens and deposits them into account 0x02 's vault
3
+ // This transaction mints tokens and deposits them into the caller 's vault
4
4
transaction {
5
5
6
6
// Local variable for storing the reference to the minter resource
7
- let mintingRef : auth ( MintEntitlement ) &ExampleToken .VaultMinter
7
+ let mintingRef : &ExampleToken .VaultMinter
8
8
9
- // Local variable for storing the reference to the Vault of
10
- // the account that will receive the newly minted tokens
11
- var receiver : Capability <&ExampleToken .Vault {ExampleToken .Receiver }>
9
+ // Local variable for storing the receiver capability of the caller
10
+ var receiver : Capability <&{ExampleToken .Receiver }>
12
11
13
12
prepare (acct : auth (Storage, Capabilities) &Account) {
14
13
// Borrow a reference to the stored, private minter resource
15
- self .mintingRef = acct.capabilities .storage.borrow< &ExampleToken.VaultMinter> (
16
- from : / storage/ MainMinter
14
+ let minter = acct.storage.borrow< &ExampleToken.VaultMinter> (
15
+ from : / storage/ CadenceFungibleTokenTutorialMinter
17
16
) ?? panic (" Could not borrow a reference to the minter" )
17
+ self .mintingRef = minter
18
18
19
- // Get the public account object for account 0x02
20
- let recipient = getAccount (0x02 )
21
-
22
- // Get their public receiver capability
23
- self .receiver = recipient.capabilities.borrow< &ExampleToken.Vault{ExampleToken.Receiver}> (
24
- / public/ MainReceiver
25
- ) ?? panic (" Could not borrow the receiver capability from account 0x02" )
19
+ // Issue a Receiver capability for the caller's Vault
20
+ let receiverCap = acct.capabilities.storage.issue< &{ExampleToken.Receiver}> (
21
+ / storage/ CadenceFungibleTokenTutorialVault
22
+ )
23
+ self .receiver = receiverCap
26
24
}
27
25
28
26
execute {
29
- // Mint 30 tokens and deposit them into the recipient 's Vault
27
+ // Mint 30 tokens and deposit them into the caller 's Vault
30
28
self .mintingRef.mintTokens (amount : 30 .0 , recipient : self .receiver)
31
29
32
- log (" 30 tokens minted and deposited to account 0x02 " )
30
+ log (" 30 tokens minted and deposited to the caller's account " )
33
31
}
34
- }
32
+ }
0 commit comments