github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/transactions/setup_flow_token_account.cdc (about) 1 // This transaction is a template for a transaction 2 // to add a Vault resource to their account 3 // so that they can use the exampleToken 4 import FungibleToken from 0xee82856bf20e2aa6 5 import FlowToken from 0x0ae53cb6e3f42a79 6 7 transaction { 8 9 prepare(signer: AuthAccount) { 10 11 if signer.borrow<&FlowToken.Vault>(from: /storage/flowTokenBalance) == nil { 12 // Create a new flowToken Vault and put it in storage 13 signer.save(<-FlowToken.createEmptyVault(), to: /storage/flowTokenBalance) 14 15 // Create a public capability to the Vault that only exposes 16 // the deposit function through the Receiver interface 17 signer.link<&FlowToken.Vault{FungibleToken.Receiver}>( 18 /public/flowTokenReceiver, 19 target: /storage/flowTokenBalance 20 ) 21 22 // Create a public capability to the Vault that only exposes 23 // the balance field through the Balance interface 24 signer.link<&FlowToken.Vault{FungibleToken.Balance}>( 25 /public/flowTokenBalance, 26 target: /storage/flowTokenBalance 27 ) 28 } 29 } 30 }