You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cadence-migration-guide/core-contracts-guide.mdx
+22-28Lines changed: 22 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,31 +4,25 @@ sidebar_position: 4
4
4
sidebar_label: Core Contracts Guide
5
5
---
6
6
7
-
##Protocol Smart Contracts in Cadence 1.0
7
+
# Protocol Smart Contracts in Cadence 1.0
8
8
9
-
On September 4th, 2024 the Flow Mainnet upgraded to Cadence 1.0.
10
-
In addition to many changes to the Cadence programming language and
11
-
the Cadence token standards, the Flow Protocol smart contracts
12
-
also updated to be compatible with the changes.
9
+
:::important
13
10
14
-
All applications that interact with these contracts need to update their transactions and scripts
15
-
in order to be compatible with the changes.
11
+
On September 4th, 2024, the Flow Mainnet upgraded to Cadence 1.0. In addition to many changes to the Cadence programming language and the Cadence token standards, the Flow Protocol smart contracts were also updated to be compatible with the changes.
16
12
17
-
## Important Info
13
+
All applications that interact with these contracts need to update their transactions and scripts in order to be compatible with these changes.
18
14
19
-
This document assumes you have a basic understanding of the
20
-
[Cadence 1.0 improvements](./improvements.md) and modifications to the Fungible Token Standard.
21
-
We encourage you to consult those guides for more details on these changes if you are interested.
15
+
:::
22
16
23
-
The updated code for the Cadence 1.0 versions of the protocol smart contracts is located in the
24
-
[`master` branch of the flow-core-contracts repo](https://github.com/onflow/flow-core-contracts).
25
-
Please look at the [PR that made the changes](https://github.com/onflow/flow-core-contracts/pull/319)
26
-
to understand how the contracts have changed. Every contract in the repo changed.
17
+
## Important info
27
18
28
-
Additionally, here are the import addresses
29
-
for all of the important contracts related to the protocol:
19
+
This document assumes you have a basic understanding of the [Cadence 1.0 improvements] and modifications to the Fungible Token Standard. We encourage you to consult those guides for more details on these changes if you are interested.
The updated code for the Cadence 1.0 versions of the protocol smart contracts is located in the [`master` branch of the flow-core-contracts repo]. Please look at the [PR that made the changes] to understand how the contracts have changed. Every contract in the repo changed.
22
+
23
+
Additionally, here are the import addresses for all of the important contracts related to the protocol:
See the other guides in this section of the docs for the import
53
-
addresses of other important contracts in the emulator.
46
+
See the other guides in this section of the docs for the import addresses of other important contracts in the emulator.
47
+
48
+
## Upgrade guide
49
+
50
+
The NFT guide covers a lot of common changes that are required for NFT contracts, but many of these changes will also apply to any contract on Flow, so it is still useful to read even if you don't have an NFT contract.
54
51
55
-
## Upgrade Guide
52
+
The core contracts do not have any meaningful changes outside of what is required to be compatible with Cadence 1.0 and the token standard changes. If you have questions about the core contracts changes for Cadence 1.0, please reach out to the Flow team in Discord and we will be happy to help.
56
53
57
-
The NFT guide covers a lot of common changes that are required for NFT contracts,
58
-
but many of these changes will also apply to any contract on Flow, so it is still
59
-
useful to read even if you don't have an NFT contract.
54
+
<!--Relativelinks.Willnotrenderonthepage-->
60
55
61
-
The core contracts do not have any meaningful changes outside of what is required
62
-
to be compatible with Cadence 1.0 and the token standard changes.
63
-
If you have questions about the core contracts changes for Cadence 1.0,
64
-
please reach out to the Flow team in Discord and we will be happy to help.
On September 4th, 2024, the Flow Mainnet upgraded to Cadence 1.0. In addition to many changes to the Cadence programming language, the Cadence token standards also got streamlined and improved. All applications need to migrate their existing Cadence scripts and transactions for the update. If you do not update your code, your application will not function.
12
+
13
+
:::
14
+
15
+
This document describes the changes to the Cadence Fungible Token (FT) standard. We'll be using the [`ExampleToken` contract] as an example. Many projects have used `ExampleToken` as a starting point for their projects, so it is widely applicable to most NFT developers on Flow. The upgrades required for `ExampleToken` will cover 90%+ of what you'll need to do to update your contract. Each project most likely has additional logic or features that aren't included in `ExampleToken`, but hopefully, after reading this guide, you'll understand Cadence 1.0 well enough that you can easily make any other changes that are necessary.
16
+
17
+
As always, there are plenty of people on the Flow team and in the community who are happy to help answer any questions you may have, so please reach out in Discord if you need any help.
18
+
19
+
## Important info
20
+
21
+
Please read the [FLIP] that describes the changes to the `FungibleToken` standard first.
22
+
23
+
The updated code for the V2 Fungible Token standard is located in the [`master` branch of the flow-ft repo]. Please look at the [PR that made the changes] to understand how the standard and examples have changed. Note the changes to the `FungibleTokenMetadataViews`, `Burner`, `FungibleTokenSwitchboard`, and `TokenForwarding` contracts.
24
+
25
+
Additionally, here are the import addresses for all of the important contracts related to fungible tokens. The second column is the import address if you are testing with a basic version of the emulator. The third column contains the import addresses if you are using the Cadence testing framework:
See the other guides in this section of the docs for the import
57
-
addresses of other important contracts in the emulator.
58
-
59
-
As for contracts that are important for NFT developers but aren't "core contracts",
60
-
here is information about where to find the Cadence 1.0 versions of each:
36
+
See the other guides in this section of the docs for the import addresses of other important contracts in the emulator.
61
37
62
-
**USDC:** USDC was migrated to standard bridged USDC on Flow. See the [repo](https://github.com/onflow/bridged-usdc) for the latest version of the USDC contract.
38
+
As for contracts that are important for NFT developers but aren't _core contracts_, here is information about where to find the Cadence 1.0 versions of each:
63
39
64
-
**Account Linking and Hybrid Custody:**
65
-
See [this PR in the hybrid custody repo](https://github.com/onflow/hybrid-custody/pull/164)
66
-
for updated hybrid custody contracts.
40
+
-**USDC** — USDC was migrated to standard bridged USDC on Flow. See the [repo] for the latest version of the USDC contract.
41
+
-**Account Linking and Hybrid Custody** — See [this PR in the hybrid custody repo] for updated hybrid custody contracts.
also contains versions of a lot of important contracts.
43
+
[This Discord announcement] also contains versions of a lot of important contracts.
70
44
71
-
Use the [Flow Contract Browser](https://contractbrowser.com/) to find the 1.0 code of other contracts.
45
+
Use the [Flow Contract Browser] to find the 1.0 code of other contracts.
72
46
73
-
# Migration Guide
47
+
##Migration guide
74
48
75
-
Please see the [NFT Cadence 1.0 migration guide](./nft-guide.mdx).
76
-
While the contracts aren't exactly the same, they share a huge amount of functionality,
77
-
and the changes described in that guide will cover 90% of the changes
78
-
that are needed for fungible tokens, so if you just follow those instructions
79
-
for your fungible token contract, you'll be most of the way there.
49
+
Please see the [NFT Cadence 1.0 migration guide]. While the contracts aren't exactly the same, they share a large amount of functionality, and the changes described in that guide will cover 90% of the changes that are needed for fungible tokens, so if you just follow those instructions for your fungible token contract, you'll be most of the way there.
80
50
81
51
Here, we will only describe the changes that are specific to the fungible token standard.
82
52
83
-
## `Vault` implements `FungibleToken.Vault`
53
+
###`Vault` implements `FungibleToken.Vault`
84
54
85
-
`FungibleToken.Vault` is no longer a resource type specification.
86
-
It is now an interface that inherits from `Provider`, `Receiver`, `Balance`,
87
-
`ViewResolver.Resolver`, and `Burner.Burnable`.
55
+
`FungibleToken.Vault` is no longer a resource type specification. It is now an interface that inherits from `Provider`, `Receiver`, `Balance`, `ViewResolver.Resolver`, and `Burner Burnable`.
56
+
57
+
Since `Vault` is an interface, you will need to update every instance in your code that refers to `@FungibleToken.Vault` or `&FungibleToken.Vault` to `@{FungibleToken.Vault}` or `&{FungibleToken.Vault}` respectively to show that it is now an interface specification instead of a concrete type specification.
58
+
59
+
Here's an example in `deposit()`:
88
60
89
-
Since `Vault` is an interface, you will need to update every instance in your code
90
-
that refers to `@FungibleToken.Vault` or `&FungibleToken.Vault` to
91
-
`@{FungibleToken.Vault}` or `&{FungibleToken.Vault}` respectively to show
92
-
that it is now an interface specification instead of a concrete type specification.
93
-
Example in `deposit()`:
94
61
```cadence
95
62
/// deposit now accepts a resource that implements the `FungibleToken.Vault` interface type
96
63
access(all) fun deposit(from: @{FungibleToken.Vault})
97
64
```
98
65
99
66
If you have any more questions, please ask in discord and the Flow team will be happy to assist!
0 commit comments