| Crates.io | cargo-contract |
| lib.rs | cargo-contract |
| version | 6.0.0-alpha |
| created_at | 2019-04-22 21:52:36.090506+00 |
| updated_at | 2025-05-02 14:53:01.201483+00 |
| description | Setup and deployment tool for developing smart contracts via ink! |
| homepage | https://use.ink |
| repository | https://github.com/use-ink/cargo-contract |
| max_upload_size | |
| id | 129535 |
| size | 554,218 |
cargo-contractis a CLI tool which helps you develop smart contracts for Polkadot's ink!.
ink! is a Rust eDSL which allows you to write smart contracts for blockchains built on the Substrate framework.
Guided Tutorial for Beginners • ink! Documentation Portal
More relevant links:
In addition to Rust, installation requires a C++ compiler that supports C++17. Modern releases of gcc and clang, as well as Visual Studio 2019+ should work.
Step 1: rustup component add rust-src.
Step 2: cargo install --force --locked cargo-contract.
Step 3: Install dependencies for linting.
brew install opensslexport TOOLCHAIN_VERSION=nightly-2024-09-05
rustup install $TOOLCHAIN_VERSION
rustup component add rust-src --toolchain $TOOLCHAIN_VERSION
rustup run $TOOLCHAIN_VERSION cargo install cargo-dylint dylint-link
Step 4: (Optional) Install Docker Engine to be able to produce verifiable builds.
You can always update the cargo-contract binary to the latest version by running the Step 2.
If you prefer to use Docker instead, Parity has a Docker image available on the Docker Hub:
# Pull the latest stable image.
docker pull paritytech/contracts-ci-linux
# Create a new contract in your current directory.
docker run --rm -it -v $(pwd):/sources paritytech/contracts-ci-linux \
cargo contract new --target-dir /sources my_contract
# Build the contract. This will create the contract file under
# `my_contract/target/ink/my_contract.contract`.
docker run --rm -it -v $(pwd):/sources paritytech/contracts-ci-linux \
cargo contract build --manifest-path=/sources/my_contract/Cargo.toml
Windows: If you use PowerShell, change $(pwd) to ${pwd}.
# Create a new contract in your current directory (in Windows PowerShell).
docker run --rm -it -v ${pwd}:/sources paritytech/contracts-ci-linux \
cargo contract new --target-dir /sources my_contract
Some block explorers require the contract binary to be compiled in the deterministic environment. This allows to verify that a certain contract source code matches the contract binary stored on-chain.
To achieve it, you should build your contract using Docker image we provide:
cargo contract build --verifiable
You can find more detailed documentation how to use the image here.
You can always use cargo contract help to print information on available
commands and their usage.
For each command there is also a --help flag with info on additional parameters,
e.g. cargo contract new --help.
cargo contract new my_contractCreate an initial smart contract with some scaffolding code into a new
folder my_contract .
The contract contains the source code for the Flipper
contract, which is about the simplest "smart" contract you can build ‒ a bool which gets flipped
from true to false through the flip() function.
cargo contract buildCompile the contract into a PolkaVM binary, generate
metadata for it, and bundle both together in a <name>.contract file, which you can use for
deploying the contract on-chain.
cargo contract checkCheck that the code builds for PolkaVM.
This command does not output any <name>.contract artifact to the target/ directory.
cargo contract uploadUpload a contract to a pallet-contracts enabled chain. See extrinsics.
cargo contract instantiateCreate an instance of a contract on chain. See extrinsics.
cargo contract callInvoke a message on an existing contract on chain. See extrinsics.
cargo contract accountAllows resolving an H160 contract address to the Substrate AccountId which it is mapped to.
cargo contract encodeEncodes a contract's input calls and their arguments
cargo contract decodeDecode a contract's input or output data.
This can be either an event, an invocation of a contract message, or an invocation of a contract constructor.
The argument has to be given as hex-encoding, starting with 0x.
cargo contract removeRemove a contract from a pallet-contracts enabled chain. See extrinsics.
cargo contract infoFetch and display contract information of a contract on chain. See info.
cargo contract verifyVerify that a given contract binary matches the build result of the specified workspace
cargo contract schema-generateGenerate schema and print it to STDOUT.
cargo contract verify-schemaVerify a metadata file or a contract bundle containing metadata against the schema file.
cargo contract storageFetch and display the storage of a contract on chain.
cargo contract rpcInvoke an RPC call to the node. See rpc.
Metadata Version: This project only supports metadata versions starting from V14 and onwards.
In order to publish a new version of cargo-contract:
cargo update to update Cargo.lock.metadata ➜ analyze ➜ transcode ➜ build ➜ extrinsics ➜ cargo-contract.vX.X with your version number: git tag -s vX.X.X && git push origin vX.X.X.The entire code within this repository is licensed under the GPLv3.