Contract Interface FungibleToken
_10contract interface FungibleToken {_10_10 totalSupply: UFix64_10}
The interface that Fungible Token contracts implement.
Interfaces​
resource interface Provider
​
_10resource interface Provider {_10}
The interface that enforces the requirements for withdrawing tokens from the implementing type.
It does not enforce requirements on balance
here,
because it leaves open the possibility of creating custom providers
that do not necessarily need their own balance.
resource interface Receiver
​
_10resource interface Receiver {_10}
The interface that enforces the requirements for depositing tokens into the implementing type.
We do not include a condition that checks the balance because we want to give users the ability to make custom receivers that can do custom things with the tokens, like split them up and send them to different places.
resource interface Balance
​
_10resource interface Balance {_10_10 balance: UFix64_10}
The interface that contains the balance
field of the Vault
and enforces that when new Vaults are created, the balance
is initialized correctly.
Structs & Resources​
resource Vault
​
_10resource Vault {_10_10 balance: UFix64_10}
The resource that contains the functions to send and receive tokens.
The declaration of a concrete type in a contract interface means that
every Fungible Token contract that implements the FungibleToken interface
must define a concrete Vault
resource that conforms to the Provider
, Receiver
,
and Balance
interfaces, and declares their required fields and functions
Functions​
fun createEmptyVault()
​
_10func createEmptyVault(): Vault
Allows any user to create a new Vault that has a zero balance
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 into a Vault