Skip to main content

Testnet deployment

Beginner
Getting started
Tutorial

Overview

In contrast to other blockchain networks, ICP does not have a testnet network where smart contract developers can deploy their projects to test functionality.

This is because canister smart contracts can be upgraded and changed once they have been deployed on the mainnet, and mainnet deployment is fairly cheap.

For developers who are looking for a testnet environment, however, ICP offers the playground that allows for simple, small-scale, temporary testing for free. It can be used to build and deploy canisters directly in the web browser, or it can be utilized through the dfx deploy --playground command via the CLI.

Canisters deployed to the playground use resources that are borrowed from a canister pool. Each canister has an initial amount of 0.5T cycles that it receives from the resource pool and can be used for 20 minutes once the canister has been deployed. Note that there are function limitations and restrictions imposed on canisters deployed to the playground.

For advanced developers and use cases, there are custom testnet options.

Deploying to the playground

Through dfx, canisters can be deployed directly from the CLI to the playground using the --playground flag. When this flag is used, the specified canister is deployed to the playground canister pool, and a canister URL will be returned to the developer. If no canister is specified, all canisters within the project's dfx.json file will be deployed to the playground.

This workflow enables developers to test canister functionality without needing to obtain cycles or configure other parameters that are required for deployment to the mainnet.

Prerequisites

Before you start, verify the following:

  • You have an internet connection and access to a shell terminal on your local macOS or Linux computer.

  • You have a command line interface (CLI) window open. This window is also referred to as the 'terminal' window.

  • You have downloaded and installed the IC SDK package as described in the installing the IC SDK page.

dfx deploy --playground is available in dfx versions v0.15.1 and above.

To deploy a canister to the playground, first create a new dfx project with the command:

dfx new hello_world

This command will create a new default dfx project that contains a simple 'Hello, world!' sample that includes a hello_world_backend canister with a predefined greet function.

Then, to deploy this canister to the playground, run the command:

dfx deploy hello_world_backend --playground

Once deployed, the canister can be interacted with using a command such as:

dfx canister call hello_world_backend greet '("everyone")' --network playground

This command calls the hello_world_backend canister that has been deployed to the playground using the --network flag since the playground is classified as a deployment network.

Any commands that intend to target a canister deployed to the playground must use the --playground or --network playground flag in order to target the borrowed canister(s).

Verify the command displays the return value of the greet function.

For example:

("Hello, everyone!")

Next steps

Next, you can deploy your canister on the mainnet.