Mainnet Deployment Guidelines

Note: Anyone can deploy and update contracts on mainnet. Smart contract reviews (to discover any issues that may affect your users) are still provided upon request. However, they are not mandatory.

Prerequisites

  • Testnet testing: Smart contracts include test coverage and follow any additional guidelines set out here: Smart Contract Testing Guidelines. Application live on testnet and handling real world traffic for an extended period of time as suggested here: Testnet Testing Guidelines
  • Flow CLI: You have the CLI installed and ran flow init in your project folder, generating a flow.json file
  • Mainnet account: You completed the mainnet account setup and have your key pair and mainnet address ready

Configuration

First, you need to configure the flow.json file to add your mainnet account details:

1
{
2
...
3
"accounts": {
4
"my-mainnet-account": {
5
"address": "ADDRESS_FROM_PREVIOUS_STEP",
6
"key": "PRIVATE_KEY_GENERATED_IN_PREVIOUS_STEP"
7
}
8
}
9
...
10
}

Next, you need to set the deployment target configuration for the mainnet:

1
{
2
...
3
"deployments": {
4
"mainnet": {
5
"my-mainnet-account": ["Foo", "Bar"]
6
}
7
}
8
...
9
}

Deploy a contract on mainnet using the CLI

With the configuration changes completed, run the Flow CLI deployment command:

1
> flow project deploy --network=mainnet
2
3
Deploying 2 contracts for accounts: my-mainnet-account
4
5
Foo -> 0xab7... (1e8fdb973...90b7ee38b8)
6
7
Bar -> 0xab7... (6c243d09e...b878111098)
8
9
10
✨ All contracts deployed successfully

Note: This command automatically deploys your project's contracts based on the configuration defined in your flow.json file. If you encounter any errors, review the configuration first.

Important: If you see Error Code: 1103, your new account does not have enough funds to complete the transaction. Make sure you have enough FLOW (e.g. by sending some from your Blocto account).

Once all your contracts are deployed, you can visit flow-view-source or run the Flow CLI get account command to confirm the deployment.

Update/Re-deploy a contract on mainnet using the CLI

You can use the Flow CLI contract update command to re-deploy an updated version of your contract:

1
> flow accounts update-contract Foo ./Foo.cdc --signer=my-mainnet-account --network=mainnet
2
3
Transaction ID: e0728170165ce...6956785be50
4
Contract 'Foo' updated on the account 'ab7...'.
5
6
Address 0xab7...
7
Balance 1000.00099677
8
Keys 1
9
10
Key 0 Public Key 39a097c....
11
Weight 1000
12
Signature Algorithm ECDSA_P256
13
Hash Algorithm SHA3_256
14
Revoked false
15
Sequence Number 3
16
Index 0
17
18
Contracts Deployed: 2
19
Contract: 'Foo'
20
Contract: 'Bar'
21
22
23
Contracts (hidden, use --include contracts)

NFT Discoverabilty

You should follow the steps listed in the Alchemy repository to get your NFT discovered through the Alchemy API. Make sure you added files needed to support your NFT on mainnet specifically.

Risks for Early Adopters

Breaking Changes

In these early days of Flow, version updates to Cadence, Flow Node software, and the Flow SDKs will often contain important updates as well as breaking changes.

Breaking changes will be a fact of life for early adopters of Flow's development stack, and you may often need to manually re-deploy your application's contracts after updates.

Version Compatibility

A version compatibility table can be found here. This will help you navigate version compatibility between Emulator, SDK, and Network Node (flow-go) versions.

Mainnet Sporking

"Sporking" (soft forking) is the process of upgrading Flow network node software, and migrating the state from the previous version.

Currently, historical event data is not migrated between sporks, so you'll need to design your application with this in mind. We recognize the usefulness of historical event data and plan on adding a means of accessing it in the near future.

"Real Value" on Mainnet

Unlike Flow Testnet, once your application is launched on Flow Mainnet, your users will be exchanging real value in the form of FLOW tokens (The Flow blockchain's native token) or other resources which have been made available. You or your user will also be responsible for paying transaction fees using FLOW tokens.

You can read about Transaction fees here: https://docs.onflow.org/flow-token/concepts/#fees