Developer Resources

What are Canisters?

Learn more about software canisters, the Internet Computer’s smart contracts that offer unlimited scaling potential

IC Academy » Developer Resources » What are Canisters?

Canister Smart Contracts

Smart contracts that scale

Introduction to Canisters

The Internet Computer is a blockchain that enables developers to run decentralized applications at web speed with infinite scaling potential. Its seamless software ecosystem allows applications and programs to use each other’s API and to communicate with each other.

The unique features of the Internet Computer are provided by so-called “canister smart contracts,” which are computational units consisting of both data and code. These canisters can be accessed through the internet once they are deployed to the Internet Computer.

What are Canisters?

Canisters are compute units (i.e. smart contracts) that are designed for internet-scale applications and services running at web speed. They are powered by cycles.

Canisters as Key Concept of the Internet Computer

A key concept of the IC, canisters provide the foundation for an open, private, censorship-free, and collaborative internet.

Fully deterministic smart contracts

The state of a canister can only be modified through messages that are included in the blockchain. For this reason, canisters are tamperproof as their state and execution are governed by the Internet Computer Protocol (ICP).

A result of being fully deterministic is that the state of a canister can be audited in a cryptographically-secure manner by inspecting the messages in the blockchain. Despite sharing many similarities with traditional smart contracts, Canisters’ performance characteristics make it possible to build blockchain-powered applications that scale.

Bidirectional message passing

A canister running on the Internet Computer shares many similarities to an actor in the actor model by computer scientist Carl Hewitt, which is a mathematical model of concurrent computation. For example:

To enable bidirectional message passing, the Internet Computer divides messages into responses and requests. This allows replying to requests, in which case the IC is keeping track of responses.

The feature of bidirectional message passing differentiates canisters from traditional actors. 

Overcoming the performance limitations of early smart contract platforms

The Internet computer is able to overcome performance limitations early platforms are confronted with by executing canisters in parallel. This means that while there is only one thread of execution for the updates of a single canister, all canisters on the Internet Computer’s blockchain are executed in parallel. At the same time, there is a distinction between requests and queries:

Update Requests

Requests update the canister’s state

Queries

Queries are not able to modify the canister’s state

As a result of only having one thread of execution, the update throughput of a single canister is limited by the IC’s blockchain. However, i is able to serve queries concurrently, allowing canisters to reach a throughput of thousands of queries per second with a latency measured in milliseconds.

Technical details about canisters

The Internet Computer serves a variety of different functions when it comes to managing canisters. Let’s have a look at these.

First and foremost, the Internet Computer is responsible for scheduling the execution of canisters. It also enforces the boundary of a canister’s linear memory. Another key function of the IC is to maintain state of a canister. This includes keeping track of a canister’s token balances and cycles but also of its permissions and outstanding calls.

It is not possible for a canister to directly modify its token balances.

Because canisters are hosted on the Internet Computer they have access to APIs which allow them to:

Secure randomness & canister replication

Canisters will have access to secure randomness through the Internet Computer’s APIs. This will allow them to extend beyond the ecosystem to sign contracts of the Bitcoin and Ethereum blockchain.

Aside from having access to secure randomness, canisters are replicated over all nodes of the subnetwork. This means that a canister will not crash even when it malfunctions. So instead of crashing, the canisters status rolled back before the malfunctioning message started executing. As a result, a canister will be able to continue executing new messages despite having malfunctioned.

WebAssembly module instances

Canisters are implemented on the Internet Computer as WebAssembly module instances. This allows canisters to import the IC’s System API while being able to export their own APIs that can be called by other canisters.

A canister is not just a WebAssembly module but a WebAssembly module instance.

File IO or databases are rendered obsolete because canisters are using orthogonal persistence, which makes it seem as if the module instance lives forever. Should developers wish to store a given variable persistently to the canister, they can simply write the variable to the canister’s memory.

There are two reasons why “writes” to the linear memory of a canister are tracked:

Rollback

WebAssembly traps or failed computations can be rolled back because “writes” are tracked

Replicas

Should a replica crash, it can resume operations by requesting modified pages from another replica.

The Internet Computer maintains the illusion that module instances live forever. This is made possible by providing its WebAssembly module instances with indefinite lifetime.

There are three key benefits for the Internet Computer that WebAssembly brings:

Language-agnostic programming

Developers are able to write canister smart contracts in any given programming language that compiles to WebAssembly (for example Motoko and Rust).

Deterministic execution

The deterministic execution of WebAssembly is ensured – with the exception of edge cases that can easily be ruled out

Formal semantics

With the help of WebAssembly, the Internet Computer can provide end-to-end formally verified execution environments for additional security.

Convert ICP to Cycles

Learn how you can convert ICP to cycles to power your dApp on the Internet Computer

Converting to Cycles

Deploy Canister

Find out how you can deploy a canister smart contract via the NNS dApp

Deploy Your Canister