Skip to content

Commit

Permalink
Improve explanations
Browse files Browse the repository at this point in the history
  • Loading branch information
lealobanov committed Dec 10, 2024
1 parent b934182 commit 2a287a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion explanations/contract.txt
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.
7 changes: 4 additions & 3 deletions explanations/transaction.txt
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.

0 comments on commit 2a287a2

Please sign in to comment.