14 Oct 2022
Contributed by Flow Blockchain
This explains the vault resource that can be created in order for you to handle fungible tokens.
Smart Contract Example
This is a vault resource in a smart contract that can be stored in a users account.
It keeps track of the total balance of tokens as well as the functions to withdraw and deposit tokens.
Interfaces such as Provider, Receiver, and Balance are included that allow users to send you money when executing a transaction.
Here we are creating a new Vault resource into an account.
When that is created and stored into their private storage, we then create public capabilities that others can use to check balance, or deposit tokens.
Once we do that, we check to make sure that the capabilities were indeed created and then we are done with the transaction.
Up Next: Withdrawing Tokens