Developer Resources

What is Candid?

This guide explains what Candid is and shows you how to utilize it for developing Internet Computer dApps

IC Academy » Candid Resources » What is Candid?

Introduction to Candid

Candid’s purpose and key features

What is Candid?

Candid is a language-agnostic interface description language. It serves the primary purpose of describing a service’s public interface.

In the context of the Internet Computer, Candid describes the public interface of a program running as a deployed canister smart contract. Candid enables the inter-operation between front-ends and services that are written in different programming languages, such as Motoko, Rust, and JavaScript.

Typical Interface Description in Candid

Let’s have a look how a typical description of what an interface might look like in Candid:

Copy to Clipboard

The example above illustrates how every method of the interface description consists of a sequence of arguments as well as result types. Annotations that are specific to the IC can also be included in a method, such as the query notation. The service counter described above consists of these public methods:

  • add and subtract methods for changing the counter’s value
  • get method for reading the counter’s current value
  • subscribe method for invoking another function such as a notification callback method

Candid precisely specifies changes developers can make without breaking existing clients which supports the advancement of service interfaces while avoiding lost compatibility with existing clients.

Candid’s Features

The Candid interface description language provides developers unique features that other technologies such as JSON, Protobuf, or XML are not able to offer. These features include the following:

  • Candid describes the services as a whole instead of only mapping individual values to bytes/characters
  • The focus lies on the methods that use the data types instead of focusing on the data types
  • The Candid value is mapped directly to the host language’s types and values
  • Candid allows developers to avoid having to construct or deconstruct abstract Candid values
  • Rules are defined on upgrading services and interfaces in a compositional way
  • Candid is a higher-order language, i.e. more than plain data can be passed
  • Built-in support for features specific to the Internet Computer, such as query annotations

Candid Types and Values

As a strongly typed system, Candid offers developers a typeset that canonically covers most use cases:

  • Unbounded integral number (nat, int)
  • Bounded integral number types (nat8,nat16, nat32, nat64, int8, int16, int32, int64).

  • Boolean type (bool).
  • Floating point types (float32, float64).
  • Container types, which include variants (opt, vec, record, variant).
  • Types for binary (blob) and textual (text) data.
  • Reference types (such as service, func, and principal).

  • Special types, such as null, reserved and empty.

For a detailed description of all types, have a look at the Internet Computer’s Reference section.

The aforementioned set of type is designed to describe the structure of the data, allowing information to be encoded, passed around, and decoded. However, semantic constraints are intentionally not described – beyond what’s required to describe the representation.

How Candid Works

Find out how Candid, the interface description language of the Internet Computer, works

More about how Candid works

How to Use Candid?

Learn how you can use Candid to perform typical tasks on the Internet Computer

Learn to use Candid