Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 24 additions & 28 deletions docs/build/cadence/core-contracts/02-fungible-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ keywords:
- token specification
---

# Fungible Token Contract

The `FungibleToken` contract implements the Fungible Token Standard. It is the second contract ever deployed on Flow.

- [Basic Fungible Token Tutorial](https://cadence-lang.org/docs/tutorial/fungible-tokens)
- [Fungible Token Guide](../../../blockchain-development-tutorials/tokens/fungible-token-cadence.md)
- [Fungible Token Standard Repo](https://github.com/onflow/flow-ft)
- [Basic Fungible Token Tutorial]
- [Fungible Token Guide]
- [Fungible Token Standard Repo]

The `FungibleTokenMetadataViews` and `FungibleTokenSwitchboard` contracts
are also deployed to the same account as `FungibleToken`.
The `FungibleTokenMetadataViews` and `FungibleTokenSwitchboard` contracts are also deployed to the same account as `FungibleToken`.

Source: [FungibleToken.cdc](https://github.com/onflow/flow-ft/blob/master/contracts/FungibleToken.cdc)

Expand All @@ -41,10 +42,7 @@ Source: [FungibleToken.cdc](https://github.com/onflow/flow-ft/blob/master/contra

# Transactions

All `FungibleToken` projects are encouraged to use
the generic token transactions and scripts in the `flow-ft` [repo](https://github.com/onflow/flow-ft/tree/master/transactions).
They can be used for any token that implements the fungible token standard properly
without changing any code besides import addresses on different networks.
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 any code change besides import addresses on different networks.

# Events

Expand All @@ -56,18 +54,15 @@ A.{contract address}.{contract name}.{event name}

The components of the format are:

- `contract address` - the address of the account the contract has been deployed to
- `contract name` - the name of the contract in the source code
- `event name` - the name of the event as declared in the source code
- `contract address` - the address of the account the contract has been deployed to.
- `contract name` - the name of the contract in the source code.
- `event name` - the name of the event as declared in the source code.

## FungibleToken Events
## 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.
Contracts that implement the Fungible Token standard get access to standard events that are emitted every time a relevant action occurs, like deposit and withdraw 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.
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:

Expand All @@ -76,8 +71,7 @@ A.{contract address}.FungibleToken.Deposited
A.{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.
Where the `contract address` is the `FungibleToken` address on the network being queried. The addresses on the various networks are shown above.

### FungibleToken.Deposited

Expand All @@ -92,9 +86,7 @@ access(all) event Deposited (
)
```

Whenever `deposit()` is called on a resource type that implements
`FungibleToken.Vault`, the `FungibleToken.Deposited` event is emitted
with the following arguments:
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`
Expand Down Expand Up @@ -123,9 +115,7 @@ access(all) event Withdrawn (
)
```

Whenever `withdraw()` is called on a resource type that implements
`FungibleToken.Vault`, the `FungibleToken.Withdrawn` event is emitted
with the following arguments:
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`
Expand All @@ -152,12 +142,18 @@ access(all) event Burned (
)
```

Whenever a fungible token that implements `FungibleToken.Vault` is burned
via the `Burner.burn()` method, this event is emitted with the following arguments:
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`
- `amount: UFix64`: The amount of tokens that were burnt.
- Example: `0.00017485`
- `fromUUID: UInt64`: The UUID of the Vault that was burnt.
- Example: `177021372071991`

<!-- Reference-style links, will not render on page -->

[Basic Fungible Token Tutorial]: https://cadence-lang.org/docs/tutorial/fungible-tokens
[Fungible Token Guide]: ../../../blockchain-development-tutorials/tokens/fungible-token-cadence.md
[Fungible Token Standard Repo]: https://github.com/onflow/flow-ft
[repo]: https://github.com/onflow/flow-ft/tree/master/transactions
53 changes: 30 additions & 23 deletions docs/build/cadence/core-contracts/03-flow-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ keywords:
- Flow testnet
---

# Flow Token Contract

The `FlowToken` contract defines the FLOW network token.

Source: [FlowToken.cdc](https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowToken.cdc)
Source: [FlowToken.cdc]

| Network | Contract Address |
| ------------------------- | -------------------- |
Expand All @@ -32,18 +34,16 @@ Source: [FlowToken.cdc](https://github.com/onflow/flow-core-contracts/blob/maste
| Testnet | `0x7e60df042a9c0868` |
| Mainnet | `0x1654653399040a61` |

# Transactions
## Transactions

Transactions and scripts for `FlowToken` are in the `flow-core-contracts` [repo](https://github.com/onflow/flow-core-contracts/tree/master/transactions/flowToken).
Transactions and scripts for `FlowToken` are in the `flow-core-contracts` [repo].

As mentioned in the `FungibleToken` page, developers are encouraged to use
the generic token transactions in the `flow-ft` [repo](https://github.com/onflow/flow-ft/tree/master/transactions) instead.
the generic token transactions in the [`flow-ft` repo] instead.

# Events
## Events

Flow relies on a set of core contracts that define key portions of the Flow protocol. Those contracts are core contracts
and are made to emit the events documented below. You can read about the [core contracts here](./index.md)
and view their source code and event definitions.
Flow relies on a set of core contracts that define key portions of the Flow protocol. Those contracts are core contracts and are made to emit the events documented below. You can read about the [core contracts here] and view their source code and event definitions.

Events emitted from core contracts follow a standard format:

Expand All @@ -53,18 +53,17 @@ A.{contract address}.{contract name}.{event name}

The components of the format are:

- `contract address` - the address of the account the contract has been deployed to
- `contract name` - the name of the contract in the source code
- `event name` - the name of the event as declared in the source code
- `contract address` - the address of the account the contract has been deployed to.
- `contract name` - the name of the contract in the source code.
- `event name` - the name of the event as declared in the source code.

### Flow Token Contract
### Flow token contract

Description of events emitted from the [FLOW Token contract](./03-flow-token.md).
The contract defines the fungible FLOW token. Please note that events for the fungible token contracts are the same
if deployed to a different account but the `contract address` is
changed to the address of the account the contract has been deployed to.

### Tokens Initialized
The contract defines the fungible FLOW token. Please note that events for the fungible token contracts are the same if deployed to a different account but the `contract address` is changed to the address of the account the contract has been deployed to.

### Tokens initialized

Event that is emitted when the contract gets created.

Expand All @@ -80,7 +79,7 @@ access(all) event TokensInitialized(initialSupply: UFix64)
| ------------- | ------ | -------------------------------- |
| initialSupply | UFix64 | The initial supply of the tokens |

### Tokens Withdrawn
### Tokens withdrawn

Event that is emitted when tokens get withdrawn from a Vault.

Expand All @@ -97,7 +96,7 @@ access(all) event TokensWithdrawn(amount: UFix64, from: Address?)
| amount | UFix64 | The amount of tokens withdrawn |
| from | Address? | Optional address of the account that owns the vault where tokens were withdrawn from. `nil` if the vault is not in an account's storage |

### Tokens Deposited
### Tokens deposited

Event that is emitted when tokens get deposited to a Vault.

Expand All @@ -114,7 +113,7 @@ access(all) event TokensDeposited(amount: UFix64, to: Address?)
| amount | UFix64 | The amount of tokens withdrawn |
| to | Address? | Optional address of the account that owns the vault where tokens were deposited to. `nil` if the vault is not in an account's storage |

### Tokens Minted
### Tokens minted

Event that is emitted when new tokens gets minted.

Expand All @@ -130,7 +129,7 @@ access(all) event TokensMinted(amount: UFix64)
| ------ | ------ | ---------------------------- |
| amount | UFix64 | The amount of tokens to mint |

### Tokens Burned
### Tokens burned

Event that is emitted when tokens get destroyed.

Expand All @@ -146,7 +145,7 @@ access(all) event TokensBurned(amount: UFix64)
| ------ | ------ | ---------------------------- |
| amount | UFix64 | The amount of tokens to burn |

### Minter Created
### Minter created

Event that is emitted when a new minter resource gets created.

Expand Down Expand Up @@ -174,6 +173,14 @@ Event that is emitted when a new burner Resource gets created.
access(all) event BurnerCreated()
```

### Staking Events
### Staking events

To learn more about staking events, read [staking/events/]

<!-- Reference-style links, will not render on page -->

To learn more about staking events, read [staking/events/](../../../protocol/staking/07-staking-scripts-events.md)
[FlowToken.cdc]: https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowToken.cdc
[repo]: https://github.com/onflow/flow-core-contracts/tree/master/transactions/flowToken
[`flow-ft` repo]: https://github.com/onflow/flow-ft/tree/master/transactions
[core contracts here]: ./index.md
[staking/events/]: ../../../protocol/staking/07-staking-scripts-events.md
38 changes: 20 additions & 18 deletions docs/build/cadence/core-contracts/04-service-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ keywords:
- network configuration
---

# Service Account Contracts

The service account is the account that manages the core protocol requirements of Flow.

| Network | Contract Address |
Expand All @@ -31,14 +33,13 @@ The service account is the account that manages the core protocol requirements o

Here are three important contracts deployed to the service account:

# FlowServiceAccount
## FlowServiceAccount

`FlowServiceAccount` tracks transaction fees, deployment permissions, and provides
some convenience methods for Flow Token operations.
`FlowServiceAccount` tracks transaction fees, deployment permissions, and provides some convenience methods for Flow Token operations.

Source: [FlowServiceAccount.cdc](https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowServiceAccount.cdc)
Source: [FlowServiceAccount.cdc]

## Events
### Events

Important events from `FlowServiceAccount` are:

Expand All @@ -47,16 +48,13 @@ access(all) event TransactionFeeUpdated(newFee: UFix64)
access(all) event AccountCreationFeeUpdated(newFee: UFix64)
```

# RandomBeaconHistory
## RandomBeaconHistory

- `RandomBeaconHistory` stores the history of random sources generated by
the Flow network. The defined Heartbeat resource is
updated by the Flow Service Account at the end of every block
with that block's source of randomness.
- `RandomBeaconHistory` stores the history of random sources generated by the Flow network. The defined Heartbeat resource is updated by the Flow Service Account at the end of every block with that block's source of randomness.

Source: [RandomBeaconHistory.cdc](https://github.com/onflow/flow-core-contracts/blob/master/contracts/RandomBeaconHistory.cdc)
Source: [RandomBeaconHistory.cdc]

## Events
### Events

Important events from `RandomBeaconHistory` are:

Expand All @@ -75,15 +73,13 @@ access(all) event RandomHistoryMissing(blockHeight: UInt64, gapStartHeight: UInt
access(all) event RandomHistoryBackfilled(blockHeight: UInt64, gapStartHeight: UInt64, count: UInt64)
```

# NodeVersionBeacon
## NodeVersionBeacon

- `NodeVersionBeacon` holds the past
and future protocol versions that should be used
to execute/handle blocks at a given block height.
- `NodeVersionBeacon` holds the past and future protocol versions that should be used to execute or handle blocks at a given block height.

Source: [NodeVersionBeacon.cdc](https://github.com/onflow/flow-core-contracts/blob/master/contracts/NodeVersionBeacon.cdc)
Source: [NodeVersionBeacon.cdc]

## Events
### Events

Important events from `NodeVersionBeacon` are:

Expand All @@ -102,3 +98,9 @@ access(all) event VersionBeacon(
/// freeze period is measured in blocks (from the current block).
access(all) event NodeVersionBoundaryFreezePeriodChanged(freezePeriod: UInt64)
```

<!-- Reference-style links, will not render on page -->

[FlowServiceAccount.cdc]: https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowServiceAccount.cdc
[RandomBeaconHistory.cdc]: https://github.com/onflow/flow-core-contracts/blob/master/contracts/RandomBeaconHistory.cdc
[NodeVersionBeacon.cdc]: https://github.com/onflow/flow-core-contracts/blob/master/contracts/NodeVersionBeacon.cdc
11 changes: 8 additions & 3 deletions docs/build/cadence/core-contracts/05-flow-fees.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ keywords:
- blockchain fees
---

## FlowFees
# Flow Fees Contract

The `FlowFees` contract is where all the collected flow fees are gathered.

Source: [FlowFees.cdc](https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowFees.cdc)
Source: [FlowFees.cdc]

| Network | Contract Address |
| ------------------------- | -------------------- |
Expand Down Expand Up @@ -56,7 +56,7 @@ access(all) event FeeParametersChanged(surgeFactor: UFix64, inclusionEffortCost:

The `FlowStorageFees` contract defines the parameters and utility methods for storage fees.

Source: [FlowStorageFees.cdc](https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowStorageFees.cdc)
Source: [FlowStorageFees.cdc]

| Network | Contract Address |
| ------------------------- | -------------------- |
Expand All @@ -76,3 +76,8 @@ access(all) event StorageMegaBytesPerReservedFLOWChanged(_ storageMegaBytesPerRe
// Emitted when the minimum amount of Flow tokens that an account needs to have reserved for storage capacity changes.
access(all) event MinimumStorageReservationChanged(_ minimumStorageReservation: UFix64)
```

<!-- Reference-style links, will not render on page -->

[FlowFees.cdc]: https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowFees.cdc
[FlowStorageFees.cdc]: https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowStorageFees.cdc
Loading