Skip to main content

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:

flow.json

_10
{
_10
...
_10
"accounts": {
_10
"my-mainnet-account": {
_10
"address": "ADDRESS_FROM_PREVIOUS_STEP",
_10
"key": "PRIVATE_KEY_GENERATED_IN_PREVIOUS_STEP"
_10
}
_10
}
_10
...
_10
}

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

flow.json

_10
{
_10
...
_10
"deployments": {
_10
"mainnet": {
_10
"my-mainnet-account": ["Foo", "Bar"]
_10
}
_10
}
_10
...
_10
}

Deploy a contract on mainnet using the CLI

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


_10
> flow project deploy --network=mainnet
_10
_10
Deploying 2 contracts for accounts: my-mainnet-account
_10
_10
Foo -> 0xab7... (1e8fdb973...90b7ee38b8)
_10
_10
Bar -> 0xab7... (6c243d09e...b878111098)
_10
_10
_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:


_23
> flow accounts update-contract Foo ./Foo.cdc --signer=my-mainnet-account --network=mainnet
_23
_23
Transaction ID: e0728170165ce...6956785be50
_23
Contract 'Foo' updated on the account 'ab7...'.
_23
_23
Address 0xab7...
_23
Balance 1000.00099677
_23
Keys 1
_23
_23
Key 0 Public Key 39a097c....
_23
Weight 1000
_23
Signature Algorithm ECDSA_P256
_23
Hash Algorithm SHA3_256
_23
Revoked false
_23
Sequence Number 3
_23
Index 0
_23
_23
Contracts Deployed: 2
_23
Contract: 'Foo'
_23
Contract: 'Bar'
_23
_23
_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: concepts/#fees