Skip to main content
Version: Current

Deploying Contracts

In order to deploy your smart contracts to the mainnet, you need to register, fund, and setup a new account.

info

This account will be used for production purposes. Make sure you handle keys appropriately. Using a Key Management Service is the best practice.

Creating an Account

There are two simple methods of creating an account on testnet. Interactive and Manual, both use the Flow CLI. On mainnet you will have to fund your newly created account, there is no faucet. Make sure to install the Flow CLI. Flow CLI has a interactive mode for generating keys.

tip

Anyone can deploy and update contracts on mainnet. Audits are encouraged but not mandatory to deploying contracts to mainnet. Take every precauction to reduce issues and protect users.

Create and deploy a mainnet project

  • Highly encouraged to test on Testnet, have strong smart contract test coverage and follow any additional guidelines set out here: Smart Contract Testing Guidelines.
  • Follow the Flow CLI instructions to Create a Project. You have the Flow CLI installed and ran flow init or flow setup in your project folder and generating a flow.json file
  • Mainnet account: You completed the mainnet account setup, (see above) and have your key pair and mainnet address ready.
  • Deploy your project, notice that your account now has contracts deployed on mainnet.
  • Deploy a contract to mainnet. You can deploy contracts individually using the account-add-contract command.
info

All your contract deployment addresses are stored in flow.json. Mainnet, Testnet and local (emulator) are stored as well.

Deploy updated contracts on mainnet

Contracts can be updated and retain the contract address. You can use the Flow CLI contract update command to re-deploy an updated version of your contract: docs/tools/flow-cli/accounts/account-add-contract.md

warning

If you see Error Code: 1103, your new account does not have enough funds to complete the transaction. Make sure you have enough FLOW and your account is set up correctly, check account explorer to verify Getting Started.

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

Sporks

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. Past spork transactional data is available, See Previous Spork Access Node Info

More Information on Sporks

Testnet

The Flow test network, known as Flow Testnet, exists to help developers test their software and smart contracts against a live network. It's also used as a means of releasing and testing new protocol and smart contract features before they are integrated into Flow's main network (Mainnet).

When the Flow protocol is updated or a new version of Cadence is released, those updates will always be made available on the Flow Emulator before they're integrated into Flow Testnet or Flow Mainnet.

Getting Started on Testnet

info

To create accounts and generate keys, make sure to install Flow CLI. Flow CLI provides convenient functions to simplifies interacting with the blockchain.

Creating an Account

There are two simple methods of creating an account on testnet. Interactive and Manual, both use the Flow CLI and the Testnet Faucet.

Make sure to install the Flow CLI. Flow CLI has a interactive mode for generating keys, using the testnet faucet to create and fund the new account.

Creating and deploying a Project

Flow CLI can be used to create a Cadence project and stay organized, Flow CLI: Create a project. This will make deployment much easiler and help with the iterative development process.

After you have a project created and want to deploy your Cadence; contracts, transactions and scripts.Flow CLI: deploy.

Make sure Flow project was initialized in the previous step and the flow.json is present.

Making Use of Core Contracts

Flow Testnet comes with some useful contracts already deployed, called core contracts. More information and import addresses for the core contracts.

Once your accounts are set up and you're ready to develop, you can look over some code examples from the Flow Go SDK.

Breaking Changes

The Flow blockchain is improved continuously and thus version updates to Cadence, Flow node software, and the Flow SDKs will contain important updates as well as breaking changes.

You should anticipate future updates and join the community (Forum or Discord) to stay tuned on important announcements. Notices and guidelines for changes will be provided as early as possible.

Testnet Sporking

"Sporking" (soft forking) is the process of upgrading the Flow network node software and migrating the chain state from one version to another.

Currently, historical event data is not migrated between sporks. 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. Only one previous spork data is available through old Access Node.

warning

Flow Testnet is explicitly for experimentation and testing and should not be used to exchange "real value" (e.g. developing a fiat money on/off-ramp for your testnet application).

Testnet

The Flow test network, known as Flow Testnet, exists to help developers test their software and smart contracts against a live network. It's also used as a means of releasing and testing new protocol and smart contract features before they are integrated into Flow's main network (Mainnet).

When the Flow protocol is updated or a new version of Cadence is released, those updates will always be made available on the Flow Emulator before they're integrated into Flow Testnet or Flow Mainnet.

Getting Started on Testnet

info

To create accounts and generate keys, make sure to install Flow CLI. Flow CLI provides convenient functions to simplifies interacting with the blockchain.

Creating an Account

There are two simple methods of creating an account on testnet. Interactive and Manual, both use the Flow CLI and the Testnet Faucet.

Make sure to install the Flow CLI. Flow CLI has a interactive mode for generating keys, using the testnet faucet to create and fund the new account.

Creating and deploying a Project

Flow CLI can be used to create a Cadence project and stay organized, Flow CLI: Create a project. This will make deployment much easiler and help with the iterative development process.

After you have a project created and want to deploy your Cadence; contracts, transactions and scripts.Flow CLI: deploy.

Make sure Flow project was initialized in the previous step and the flow.json is present.

Making Use of Core Contracts

Flow Testnet comes with some useful contracts already deployed, called core contracts. More information and import addresses for the core contracts.

Once your accounts are set up and you're ready to develop, you can look over some code examples from the Flow Go SDK.

Breaking Changes

The Flow blockchain is improved continuously and thus version updates to Cadence, Flow node software, and the Flow SDKs will contain important updates as well as breaking changes.

You should anticipate future updates and join the community (Forum or Discord) to stay tuned on important announcements. Notices and guidelines for changes will be provided as early as possible.

Testnet Sporking

"Sporking" (soft forking) is the process of upgrading the Flow network node software and migrating the chain state from one version to another.

Currently, historical event data is not migrated between sporks. 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. Only one previous spork data is available through old Access Node.

warning

Flow Testnet is explicitly for experimentation and testing and should not be used to exchange "real value" (e.g. developing a fiat money on/off-ramp for your testnet application).