This repo contains the IC SDK: a Software Development Kit for creating and managing canister smart contracts on the Internet Computer (ICP blockchain).
For further reading:
- Reference documentation on internetcomputer.org
- Introduction to the ICP blockchain
- Internet Computer dashboard
- Developer docs for ICP smart contracts
- Sample code of ICP smart contracts
- IC wiki
The IC SDK installation script installs several components in default locations on your local computer. The following table describes the development environment components that the installation script installs:
| Component | Description | Default location |
|---|---|---|
| dfx | Command-line interface (CLI) | /usr/local/bin/dfx |
| dfxvm | Command-line interface, version manager | /usr/local/bin/dfxvm |
| moc | Motoko runtime compiler | ~/.cache/dfinity/versions/<VERSION>/moc |
| replica | Internet Computer local network binary | ~/.cache/dfinity/versions/<VERSION>/replica |
| uninstall.sh | Script to remove the SDK and all of its components | ~/.cache/dfinity/uninstall.sh |
| versions | Cache directory that contains a subdirectory for each version of the SDK you install. | ~/.cache/dfinity/versions |
There are a few components above worth expanding on:
-
dfx -
dfxis the command-line interface for theIC SDK. This is why many commands for the IC SDK start with the command "dfx .." such asdfx newordfx stop. -
dfxvm -
dfxvmis the version manager fordfx, i.e. a CLI for selecting and managing installeddfxversions. -
Canister Development Kit (CDK) - A CDK is an adapter used by the IC SDK so a programming language has the features needed to create and manage canisters. The IC SDK comes with a few CDKs already installed for you so you can use them in the language of your choice. That is why there is a Rust CDK, Python CDK, TypeScript CDK, etc... Since CDKs are components used the SDK, some developer choose to use the CDK directly (without the
IC SDK), but typically are used as part of the wholeIC SDK.
To develop Rust projects, you will need to install Rust in your environment with the command:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
ICP smart contracts are compiled into WebAssembly modules. To support this compilation, install the wasm32-unknown-unknown target:
rustup target add wasm32-unknown-unknown
You can install the IC SDK a few different ways.
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"This command will install a binary compatible with your operating system, and add it to /usr/local/bin.
Find a release for your architecture here.
in GitHub Action, using dfinity/setup-dfx
steps:
- name: Install dfx
uses: dfinity/setup-dfx@mainOnce the IC SDK is installed, get acquainted with its capabilities by entering.
dfx helpSee our contributing guidelines here.
Building the IC SDK is very simple:
cargo buildIC SDK is released in two steps:
-
Publishing a new
IC SDKrelease. -
Publishing a new
manifest.jsonandinstall.shto instruct the installer to actually download and install the newIC SDKrelease.
-
The release manager makes sure the
dfxstablebranch points to the revision that should be released and that the revision is tagged with a version (like0.5.6). -
The
sdk-releasejobset on Hydra tracks thestablebranch and starts evaluating shortly afterstableadvances. -
As you can see it only has the single job
publish.dfxwhich is defined here in terms of thedfxjob. Note that thepublish.dfxjob only exists when the revision has a proper version tag. This prevents publishing of untagged revisions. -
Our CD system running at
deployer.dfinity.systemsis configured with thepublish-sdk-dfx-releasejob. It will monitor the aforementionedpublish.dfxjob for new builds, whenever there's a new build it will download the output (the CD script) and execute it. -
As you can see the script also sends a message to the
#build-notificationsSlack channel so you can see when and if the SDK has been published.
After the IC SDK has been released it's available for download but the install
script at https://sdk.dfinity.org/install.sh won't immediately install it. To
make sure the installer actually downloads and installs the new IC SDK release the
manifest.json file at https://sdk.dfinity.org/manifest.json has to set its
tags.latest field to the new version. The following explains how to do that.
-
Edit the
public/manifest.jsonfile such that it points to the newIC SDKversion and make sure this is merged inmaster. -
Similarly to releasing the
IC SDKthere's ainstall-shjob that builds a CD script for publishing themanifest.jsonandinstall.shto our CDN. -
This job is built on the
sdkjobset which tracks themasterbranch. -
deployer.dfinity.systemsis configured with thepublish-sdk-install-shjob which will monitor the aforementionedpublish.install-sh.x86_64-linuxjob for new builds, whenever there's a new build it will download the output (the CD script) and execute it.
This section provides solutions to problems you might encounter when using the IC SDK via dfx command line
This command will remove the build directory and restart your replica:
dfx stop && dfx start --clean --backgroundYou can deploy the Internet Identity canister into your replica alongside your project by cloning https://github.com/dfinity/internet-identity. From the internet-identity directory, run the following command:
II_ENV=development dfx deploy --no-wallet --argument '(null)'There are more notes at https://github.com/dfinity/internet-identity#running-locally that may be helpful.