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/build/tools/flow-cli/flow.json/configuration.md
+39-3Lines changed: 39 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,6 +155,42 @@ Use aliases when contracts are already deployed on specific networks:
155
155
- To avoid redeploying dependencies
156
156
- To use the official versions of common contracts
157
157
158
+
#### Cadence Import Aliasing
159
+
160
+
When deploying the same contract to multiple addresses with different names, use the `canonical` field to reference the original contract. This allows you to import multiple instances of the same contract with different identifiers.
161
+
162
+
```json
163
+
"contracts": {
164
+
"FUSD": {
165
+
"source": "./contracts/FUSD.cdc",
166
+
"aliases": {
167
+
"testnet": "0x9a0766d93b6608b7"
168
+
}
169
+
},
170
+
"FUSD1": {
171
+
"source": "./contracts/FUSD.cdc",
172
+
"aliases": {
173
+
"testnet": "0xe223d8a629e49c68"
174
+
},
175
+
"canonical": "FUSD"
176
+
}
177
+
}
178
+
```
179
+
180
+
Flow CLI automatically transforms imports for aliased contracts:
181
+
182
+
```cadence
183
+
import "FUSD"
184
+
import "FUSD1"
185
+
```
186
+
187
+
Becomes:
188
+
189
+
```cadence
190
+
import FUSD from 0x9a0766d93b6608b7
191
+
import FUSD as FUSD1 from 0xe223d8a629e49c68
192
+
```
193
+
158
194
### Deployments
159
195
160
196
The `deployments` section defines which contracts get deployed to which accounts on which networks.
@@ -201,7 +237,7 @@ Here's a complete `flow.json` for a project with multiple contracts and networks
201
237
"testnet": "access.devnet.nodes.onflow.org:9000",
202
238
"mainnet": "access.mainnet.nodes.onflow.org:9000"
203
239
},
204
-
240
+
205
241
"accounts": {
206
242
"emulator-account": {
207
243
"address": "f8d6e0586b0a20c7",
@@ -212,7 +248,7 @@ Here's a complete `flow.json` for a project with multiple contracts and networks
0 commit comments