Contract ExampleToken
_12contract ExampleToken {_12_12 totalSupply: UFix64_12_12 VaultStoragePath: StoragePath_12_12 ReceiverPublicPath: PublicPath_12_12 VaultPublicPath: PublicPath_12_12 AdminStoragePath: StoragePath_12}
Implemented Interfaces:
FungibleToken
Structs & Resources​
resource Vault
​
_10resource Vault {_10_10 balance: UFix64_10}
Each user stores an instance of only the Vault in their storage The functions in the Vault and governed by the pre and post conditions in FungibleToken when they are called. The checks happen at runtime whenever a function is called.
Resources can only be created in the context of the contract that they are defined in, so there is no way for a malicious user to create Vaults out of thin air. A special Minter resource needs to be defined to mint new tokens.
resource Administrator
​
_10resource Administrator {_10}
resource Minter
​
_10resource Minter {_10_10 allowedAmount: UFix64_10}
Resource object that token admin accounts can hold to mint new tokens.
resource Burner
​
_10resource Burner {_10}
Resource object that token admin accounts can hold to burn tokens.
Functions​
fun createEmptyVault()
​
_10func createEmptyVault(): Vault
Function that creates a new Vault with a balance of zero and returns it to the calling context. A user must call this function and store the returned Vault in their storage in order to allow their account to be able to receive deposits of this token type.
Returns: The new Vault resource
Events​
event TokensInitialized
​
_10event TokensInitialized(initialSupply UFix64)
The event that is emitted when the contract is created
event TokensWithdrawn
​
_10event TokensWithdrawn(amount UFix64, from Address?)
The event that is emitted when tokens are withdrawn from a Vault
event TokensDeposited
​
_10event TokensDeposited(amount UFix64, to Address?)
The event that is emitted when tokens are deposited to a Vault
event TokensMinted
​
_10event TokensMinted(amount UFix64)
The event that is emitted when new tokens are minted
event TokensBurned
​
_10event TokensBurned(amount UFix64)
The event that is emitted when tokens are destroyed
event MinterCreated
​
_10event MinterCreated(allowedAmount UFix64)
The event that is emitted when a new minter resource is created
event BurnerCreated
​
_10event BurnerCreated()
The event that is emitted when a new burner resource is created