-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b934182
commit 2a287a2
Showing
2 changed files
with
5 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
This function is included in the smart contract so that anyone can create a vault resource and then save it to their account. | ||
The createEmptyVault function is a simple utility within the ExampleToken contract that creates and returns a new instance of the Vault resource. This new Vault is initialized with a balance of 0.0 tokens, meaning it starts empty. The function uses the create Vault(balance: 0.0) syntax to create this new Vault resource. The resulting Vault is then returned as a reference (@Vault), which can be used to store and manage tokens later. This function is typically used when setting up a new account or when a fresh vault is needed to hold tokens, ensuring that the vault starts with no tokens in it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
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. | ||
This transaction sets up an account to store and manage tokens using the ExampleToken contract. It begins by creating a new, empty Vault to hold tokens, which is initialized with a balance of 0.0. This vault is then stored in the account's private storage. | ||
|
||
Once we do that, we check to make sure that the capabilities were indeed created and then we are done with the transaction. | ||
After that, the transaction creates two public capabilities: one for the Receiver interface, allowing others to deposit tokens into the vault, and another for the Balance interface, enabling others to check the vault's balance. These capabilities are published to public paths so they can be accessed externally. | ||
|
||
Finally, the transaction checks that the public capability for receiving tokens was correctly created by attempting to borrow it from the account. |