The FungibleToken
contract implements the Fungible Token Standard. It is the second contract ever deployed on Flow.
The FungibleTokenMetadataViews
and FungibleTokenSwitchboard
contracts
are also deployed to the same account as FungibleToken
.
Source: FungibleToken.cdc
Network | Contract Address |
---|---|
Emulator | 0xee82856bf20e2aa6 |
Cadence Testing Framework | 0x0000000000000002 |
Testnet | 0x9a0766d93b6608b7 |
Mainnet | 0xf233dcee88fe0abe |
Transactions
All FungibleToken
projects are encouraged to use
the generic token transactions and scripts in the flow-ft
repo.
They can be used for any token that implements the fungible token standard properly
without changing any code besides import addresses on different networks.
Events
Events emitted from all contracts follow a standard format:
_10A.{contract address}.{contract name}.{event name}
The components of the format are:
contract address
- the address of the account the contract has been deployed tocontract name
- the name of the contract in the source codeevent name
- the name of the event as declared in the source code
FungibleToken Events
Contracts that implement the Fungible Token standard get access to standard events that are emitted every time a relevant action occurs, like depositing and withdrawing tokens.
This means that projects do not have to implement their own custom events unless the standard events do not satisfy requirements they have for events.
The FungibleToken
events will have the following format:
_10A.{contract address}.FungibleToken.Deposited_10A.{contract address}.FungibleToken.Withdrawn
Where the contract address
is the FungibleToken
address on the network being queried.
The addresses on the various networks are shown above.
FungibleToken.Deposited
_10access(all) event Deposited (_10 type: String,_10 amount: UFix64,_10 to: Address?,_10 toUUID: UInt64,_10 depositedUUID: UInt64,_10 balanceAfter: UFix64_10)
Whenever deposit()
is called on a resource type that implements
FungibleToken.Vault
, the FungibleToken.Deposited
event is emitted
with the following arguments:
type: String
: The type identifier of the token being deposited.- Example:
A.4445e7ad11568276.FlowToken.Vault
- Example:
amount: UFix64
: The amount of tokens that were deposited.- Example:
0.00017485
- Example:
to: Address?
: The address of the account that owns the Vault that received the tokens. If the vault is not stored in an account,to
will benil
.- Example:
0x4445e7ad11568276
- Example:
toUUID: UInt64
: The UUID of the Vault that received the tokens.- Example:
177021372071991
- Example:
depositedUUID
: The UUID of the Vault that was deposited (and therefore destroyed).- Example:
177021372071991
- Example:
balanceAfter: UFix64
: The balance of the Vault that received the tokens after the deposit happened.- Example:
1.00047545
- Example:
FungibleToken.Withdrawn
_10access(all) event Withdrawn (_10 type: String,_10 amount: UFix64,_10 from: Address?,_10 fromUUID: UInt64,_10 withdrawnUUID: UInt64,_10 balanceAfter: UFix64_10)
Whenever withdraw()
is called on a resource type that implements
FungibleToken.Vault
, the FungibleToken.Withdrawn
event is emitted
with the following arguments:
type: String
: The type identifier of the token being withdrawn.- Example:
A.4445e7ad11568276.FlowToken.Vault
- Example:
amount: UFix64
: The amount of tokens that were withdrawn.- Example:
0.00017485
- Example:
from: Address?
: The address of the account that owns the Vault that the tokens were withdrawn from. If the vault is not stored in an account,to
will benil
.- Example:
0x4445e7ad11568276
- Example:
fromUUID: UInt64
: The UUID of the Vault that the tokens were withdrawn from.- Example:
177021372071991
- Example:
withdrawnUUID
: The UUID of the Vault that was withdrawn.- Example:
177021372071991
- Example:
balanceAfter: UFix64
: The balance of the Vault that the tokens were withdrawn from after the withdrawal.- Example:
1.00047545
- Example:
FungibleToken.Burned
_10access(all) event Burned (_10 type: String,_10 amount: UFix64,_10 fromUUID: UInt64_10)
Whenever a fungible token that implements FungibleToken.Vault
is burned
via the Burner.burn()
method, this event is emitted with the following arguments:
type: String
: The type identifier of the token that was burnt.- Example:
A.4445e7ad11568276.FlowToken.Vault
- Example:
amount: UFix64
: The amount of tokens that were burnt.- Example:
0.00017485
- Example:
fromUUID: UInt64
: The UUID of the Vault that was burnt.- Example:
177021372071991
- Example: