Skip to main content

Contract ExampleToken


_12
contract 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


_10
resource 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.

More...


resource Administrator


_10
resource Administrator {
_10
}

More...


resource Minter


_10
resource Minter {
_10
_10
allowedAmount: UFix64
_10
}

Resource object that token admin accounts can hold to mint new tokens.

More...


resource Burner


_10
resource Burner {
_10
}

Resource object that token admin accounts can hold to burn tokens.

More...


Functions

fun createEmptyVault()


_10
func 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


_10
event TokensInitialized(initialSupply UFix64)

The event that is emitted when the contract is created


event TokensWithdrawn


_10
event TokensWithdrawn(amount UFix64, from Address?)

The event that is emitted when tokens are withdrawn from a Vault


event TokensDeposited


_10
event TokensDeposited(amount UFix64, to Address?)

The event that is emitted when tokens are deposited to a Vault


event TokensMinted


_10
event TokensMinted(amount UFix64)

The event that is emitted when new tokens are minted


event TokensBurned


_10
event TokensBurned(amount UFix64)

The event that is emitted when tokens are destroyed


event MinterCreated


_10
event MinterCreated(allowedAmount UFix64)

The event that is emitted when a new minter resource is created


event BurnerCreated


_10
event BurnerCreated()

The event that is emitted when a new burner resource is created