Skip to content

Commit

Permalink
Merge branch 'main' into gio/fix-random-link
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Sep 30, 2024
2 parents bdaaad6 + 115dc67 commit 77c7f48
Show file tree
Hide file tree
Showing 27 changed files with 952 additions and 273 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ The contribution process is designed to be straightforward and collaborative. He

Note: Previews are built for each Git branch by Vercel workflow.

For additional assistance or integration support, feel free to request help in the `#devex-builders` [Discord channel](https://discord.com/channels/613813861610684416/1123314820763111465) on the [Flow Discord](https://discord.gg/flowblockchain) server.
For additional assistance or integration support, feel free to request help in the `#devex-builders` channel on the [Flow Discord](https://discord.gg/flow) server.


## Updating Existing Content

Expand Down
6 changes: 3 additions & 3 deletions docs/build/advanced-concepts/randomness.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Flow On-chain Randomness
sidebar_label: VRF (Randomness)
title: Flow On-chain Randomness in Cadence
sidebar_label: VRF (Randomness) in Cadence
---

# Randomness on FLOW
Expand Down Expand Up @@ -199,4 +199,4 @@ If you’d like to dive deeper into Flow’s onchain randomness, here’s a list
- These documents provide a more in-depth technical understanding of the updates and enhancements to the Flow blockchain.
- **[FLIP 120: Update unsafeRandom function](https://github.com/onflow/flips/blob/main/cadence/20230713-random-function.md#flip-120-update-unsaferandom-function)**
- **[FLIP 123: On-chain Random beacon history for commit-reveal schemes](https://github.com/onflow/flips/blob/main/protocol/20230728-commit-reveal.md#flip-123-on-chain-random-beacon-history-for-commit-reveal-schemes)**
- To see working Cadence code, explore the [coin toss example on GitHub](https://github.com/onflow/random-coin-toss/tree/update-prg-impl).
- To see working Cadence code, explore the [coin toss example on GitHub](https://github.com/onflow/random-coin-toss).
55 changes: 43 additions & 12 deletions docs/build/basics/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,54 @@ A simple representation of an account:

![Screenshot 2023-08-16 at 16.43.07.png](_accounts_images/Screenshot_2023-08-16_at_16.43.07.png)

**Address**
## Address

A Flow address is represented as 16 hex-encoded characters (usually prefixed with `0x` to indicate hex encoding). Unlike Bitcoin and Ethereum, Flow addresses are not derived from cryptographic public keys. Instead, each Flow address is assigned by the Flow protocol using an on-chain deterministic sequence. The sequence uses an error detection code to guarantee that all addresses differ with at least 2 hex characters. This makes typos resulting in accidental loss of assets not possible.

This decoupling is a unique advantage of Flow, allowing for multiple public keys to be associated with one account, or for a single public key to be used across several accounts.

**Balance**
## Balance

Each Flow account created on Mainnet will by default [hold a Flow vault that holds a balance and is part of the FungibleToken standard](./flow-token.md). This balance is used to pay for [transaction fees and storage fees](./fees.md). More on that in the fees document.

<Callout type="warning">
:::warning

The minimum amount of FLOW an account can have is **0.001**.
</Callout>

:::

This minimum storage fee is provided by the account creator and covers the cost of storing up to 100kB of data in perpetuity. This fee is applied only once and can be "topped up" to add additional storage to an account. The minimum account reservation ensures that most accounts won't run out of storage capacity if anyone deposits anything (like an NFT) to the account.

**Contracts**

### Maximum available balance

Due to the storage restrictions, there is a maximum available balance that user can withdraw from the wallet. The core contract [`FlowStorageFees`](../core-contracts/05-flow-fees.md#flowstoragefees) provides a function to retrieve that value:

```cadence
import "FlowStorageFees"
access(all) fun main(accountAddress: Address): UFix64 {
return FlowStorageFees.defaultTokenAvailableBalance(accountAddress)
}
```

Alternatively developers can use `availableBalance` property of the `Account`

```cadence
access(all) fun main(address: Address): UFix64 {
let acc = getAccount(address)
let balance = acc.availableBalance
return balance
}
```

## Contracts

An account can optionally store multiple [Cadence contracts](https://cadence-lang.org/docs/language/contracts). The code is stored as a human-readable UTF-8 encoded string which makes it easy for anyone to inspect the contents.

**Storage**
## Storage

Each Flow account has an associated storage and capacity. The account's storage used is the byte size of all the data stored in the account's storage. An account's [storage capacity is directly tied to the balance of Flow tokens](./fees.md#storage) an account has. An account can, without any additional cost, use any amount of storage up to its storage capacity. If a transaction puts an account over storage capacity or drops an account's balance below the minimum 0.001 Flow tokens, that transaction fails and is reverted.

Expand All @@ -56,9 +83,11 @@ During account creation, public keys can be provided which will be used when int

Each account key has a weight that determines the signing power it holds.

<Callout type="warning">
:::warning

A transaction is not authorized to access an account unless it has a total signature weight greater than or equal to **1000**, the weight threshold.
</Callout>

:::

For example, an account might contain 3 keys, each with 500 weight:

Expand Down Expand Up @@ -104,10 +133,11 @@ An account on Flow doesn’t require keys in order to exist, but this makes the

You can achieve keyless accounts by either removing an existing public key from an account signing with that same key and repeating that action until an account has no keys left, or you can create a new account that has no keys assigned. With account linking you can also have a child account that has no keys but is controlled by the parent.

<Callout type="danger">
:::danger

Be careful when removing keys from an existing account, because once an account’s total key weights sum to less than 1000, it can no longer be modified.

</Callout>
:::

### **Multi-Sig Accounts**

Expand Down Expand Up @@ -143,10 +173,11 @@ For development purposes, [you can use Flow CLI to easily create emulator, testn

Keys should be generated in a secure manner. Depending on the purpose of the keys different levels of caution need to be taken.

<Callout type="warning">
:::warning

Anyone obtaining access to a private key can modify the account the key is associated with (assuming it has enough weight). Be very careful how you store the keys.

</Callout>
:::

For secure production keys, we suggest using key management services such as [Google key management](https://cloud.google.com/security-key-management) or [Amazon KMS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Encryption.Keys.html), which are also supported by our CLI and SDKs. Those services are mostly great when integrated into your application. However, for personal use, you can securely use any [existing wallets](../../ecosystem/wallets.md) as well as a [hardware Ledger wallet](../../ecosystem/wallets.md).

Expand Down
33 changes: 29 additions & 4 deletions docs/build/basics/fees.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,21 @@ Flow's approach to storage capacity is a bit similar to some banks' pricing mode

Each Flow account has associated storage used. The account's storage used is the byte size of all the data stored in the account's storage. Accounts also have a storage capacity, which is directly tied to the amount of Flow tokens an account has. The account can, without any additional cost, use any amount of storage up to its storage capacity. 

<Callout type="warning">
:::warning

If a transaction puts an account over storage capacity, that transaction fails and is reverted. Likewise, if a transaction would drop an account's balance below 0.001 Flow tokens, which is the minimum an account can have, the transaction would also fail.

</Callout>
:::

**Storage Capacity**

The storage capacity of an account is dictated by the amount of FLOW it has. 

<Callout type="danger">
:::danger

The **minimum amount of FLOW an account can have is 0.001**. This minimum is provided by the account creator at account creation.

</Callout>
:::

The minimum account reservation ensures that most accounts won't run out of storage capacity if anyone deposits anything (like an NFT) to the account.

Expand Down Expand Up @@ -119,6 +121,29 @@ Adding additional keys, smart contracts, capabilities, resources, etc. to the ac

Data stored on the Flow blockchain is stored in a key-value ledger. Each item’s key contains the address that owns the item and the path to the item. An account can have many keys, therefore flow considers the account key items are stored with. This means that the storage used by each item is the byte length of the item plus the byte length of the item’s key.

### Maximum available balance

Due to the storage restrictions, there is a maximum available balance that user can withdraw from the wallet. The core contract [`FlowStorageFees`](../core-contracts/05-flow-fees.md#flowstoragefees) provides a function to retrieve that value:

```cadence
import "FlowStorageFees"
access(all) fun main(accountAddress: Address): UFix64 {
return FlowStorageFees.defaultTokenAvailableBalance(accountAddress)
}
```

Alternatively developers can use `availableBalance` property of the `Account`

```cadence
access(all) fun main(address: Address): UFix64 {
let acc = getAccount(address)
let balance = acc.availableBalance
return balance
}
```

## Practical Understanding of Fees

Expand Down
8 changes: 4 additions & 4 deletions docs/build/core-contracts/05-flow-fees.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 5
sidebar_label: Flow Fees
---

# FlowFees
## FlowFees

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

Expand All @@ -17,7 +17,7 @@ Source: [FlowFees.cdc](https://github.com/onflow/flow-core-contracts/blob/master
| Testnet | `0x912d5440f7e3769e` |
| Mainnet | `0xf919ee77447b7497` |

## Events
### Events

Important events for `FlowFees` are:

Expand All @@ -35,7 +35,7 @@ access(all) event FeesDeducted(amount: UFix64, inclusionEffort: UFix64, executio
access(all) event FeeParametersChanged(surgeFactor: UFix64, inclusionEffortCost: UFix64, executionEffortCost: UFix64)
```

# FlowStorageFees
## FlowStorageFees

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

Expand All @@ -48,7 +48,7 @@ Source: [FlowStorageFees.cdc](https://github.com/onflow/flow-core-contracts/blob
| Testnet | `0x8c5303eaa26202d6` |
| Mainnet | `0xe467b9dd11fa00df` |

## Events
### Events

Important events for `FlowStorageFees` are:

Expand Down
2 changes: 1 addition & 1 deletion docs/build/guides/flow-app-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This guide assumes a good understanding of React. The concepts are easy to under
- [Query the Blockchain](#query-the-blockchain)
- [Mutate the Blockchain](#mutate-the-blockchain)

For more help, [Discord](https://discord.gg/flowblockchain). See links at the end of this article for diving deeper into building on Flow.
For more help, [Discord](https://discord.com/invite/J6fFnh2xx6). See links at the end of this article for diving deeper into building on Flow.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion docs/evm/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The MEV Resilient design on Flow offers DeFi builders improved market efficiency

## Join the Community

Are you interested in launching an EVM project on Flow or partnering with us? Visit our weekly Flow [office hours](https://calendar.google.com/calendar/ical/c_47978f5cd9da636cadc6b8473102b5092c1a865dd010558393ecb7f9fd0c9ad0%40group.calendar.google.com/public/basic.ics) for discussions on project development and other opportunities for collaboration. You can also chat with us in the Flow [Discord](https://discord.com/channels/613813861610684416/1167476806333513800).
Are you interested in launching an EVM project on Flow or partnering with us? Visit our weekly Flow [office hours](https://calendar.google.com/calendar/ical/c_47978f5cd9da636cadc6b8473102b5092c1a865dd010558393ecb7f9fd0c9ad0%40group.calendar.google.com/public/basic.ics) for discussions on project development and other opportunities for collaboration. You can also chat with us developers-chat in the Flow [Discord](https://discord.gg/flow).


## Further Reading and Discussions
Expand Down
19 changes: 9 additions & 10 deletions docs/evm/cadence/interacting-with-coa.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ import "EVM"
access(all)
fun main(address: Address): EVM.EVMAddress {
// Get the desired Flow account holding the COA in storage
let account: = getAuthAccount<auth(Storage) &Account>(address)
let account = getAuthAccount<auth(Storage) &Account>(address)
// Borrow a reference to the COA from the storage location we saved it to
let coa = account.storage.borrow<&EVM.CadenceOwnedAccount>(
Expand Down Expand Up @@ -168,7 +168,7 @@ import "EVM"
access(all)
fun main(address: Address): EVM.Balance {
// Get the desired Flow account holding the COA in storage
let account: = getAuthAccount<auth(Storage) &Account>(address)
let account = getAuthAccount<auth(Storage) &Account>(address)
// Borrow a reference to the COA from the storage location we saved it to
let coa = account.storage.borrow<&EVM.CadenceOwnedAccount>(
Expand Down Expand Up @@ -217,9 +217,8 @@ transaction(amount: UFix64) {
prepare(signer: auth(BorrowValue) &Account) {
// Borrow the public capability to the COA from the desired account
// This script could be modified to deposit into any account with a `EVM.CadenceOwnedAccount` capability
self.coa = signer.capabilities.borrow<&EVM.CadenceOwnedAccount>(
from: /public/evm
) ?? panic("Could not borrow reference to the COA")
self.coa = signer.capabilities.borrow<&EVM.CadenceOwnedAccount>(/public/evm)
?? panic("Could not borrow reference to the COA")
// Withdraw the balance from the COA, we will use this later to deposit into the receiving account
let vaultRef = signer.storage.borrow<auth(FungibleToken.Withdraw) &FlowToken.Vault>(
Expand All @@ -230,7 +229,7 @@ transaction(amount: UFix64) {
execute {
// Deposit the withdrawn tokens into the COA
coa.deposit(from: <-self.sentVault)
self.coa.deposit(from: <-self.sentVault)
}
}
```
Expand Down Expand Up @@ -276,7 +275,7 @@ transaction(amount: UFix64) {
execute {
// Deposit the withdrawn tokens into the receiving vault
receiver.deposit(from: <-self.sentVault)
self.receiver.deposit(from: <-self.sentVault)
}
}
```
Expand All @@ -294,7 +293,7 @@ This transaction will use the signer's COA to call a contract method with the de
```cadence
import "EVM"
transaction(evmContractHex: String, signature: String, args: [AnyStruct], gasLimit: UInt64, value: UFix64) {
transaction(evmContractHex: String, signature: String, args: [AnyStruct], gasLimit: UInt64, flowValue: UFix64) {
let coa: auth(EVM.Call) &EVM.CadenceOwnedAccount
prepare(signer: auth(BorrowValue) &Account) {
Expand All @@ -314,11 +313,11 @@ transaction(evmContractHex: String, signature: String, args: [AnyStruct], gasLim
)
// Define the value as EVM.Balance struct
let value = EVM.Balance(attoflow: 0)
value.setFLOW(flow: value)
value.setFLOW(flow: flowValue)
// Call the contract at the given EVM address with the given data, gas limit, and value
// These values could be configured through the transaction arguments or other means
// however, for simplicity, we will hardcode them here
let result: EVM.Result = coa.call(
let result: EVM.Result = self.coa.call(
to: contractAddress,
data: calldata,
gasLimit: gasLimit,
Expand Down
2 changes: 1 addition & 1 deletion docs/networks/flow-port/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ Please see a list [here](https://github.com/onflow/flow/blob/master/nodeoperator

6. I am clicking 'submit' to execute a transaction, but nothing is happening. How can I unblock myself?

- a.) Please disable any pop-up blockers and ad blockers you have and refresh the page. If you are still experiencing issues, please reach out via [Discord](https://discord.gg/4yGnMzkZxr) in the appropriate channel.
- a.) Please disable any pop-up blockers and ad blockers you have and refresh the page. If you are still experiencing issues, please reach out via [Discord](https://discord.gg/flow) in the appropriate channel.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ tar -xvf boot-tools.tar

```shell CheckSHA256
sha256sum ./boot-tools/bootstrap
315f4ff5cf85a20a05fe1c37aaa1beaad7733b488ca80605a8f7ef00f797d445 ./boot-tools/bootstrap
460cfcfeb52b40d8b8b0c4641bc4e423bcc90f82068e95f4267803ed32c26d60 ./boot-tools/bootstrap
```

> If you have downloaded the bootstrapping kit previously, ensure the SHA256 hash for it still matches. If not, re-download to ensure you are using the most up-to-date version.
Expand Down
Loading

0 comments on commit 77c7f48

Please sign in to comment.