LogoLogo
HomeExplorerGitHub
  • 🗂️Introduction
    • 🧐5Ws-1H about CESS
    • ✨Technical Highlight
    • 🔨Use Cases
    • 📜Whitepaper
    • 💬Contact & Social Media
  • ⛏️CESS Nodes
    • Consensus Nodes
      • Running a Consensus Node
      • Reward Mechanism
    • Storage Nodes
      • Running a Storage Node
      • Running MultiNodes
      • Node Troubleshooting
      • Storage Miner Upgrade Guide
    • CDN Nodes
      • Running a Cacher
      • Running a Retriever
    • TEE Nodes
      • What is TEE Node
      • Running a TEE Node
  • 🌏Community Members
    • Ambassador Program
    • Community Governance
  • 🔥CESS User Guide
    • CESS Account
    • Testnet Faucet
    • Territory Operation
  • 💻Developers
    • CESS SDK
      • Golang SDK
        • Preface
        • Install
        • Initialization
        • Properties
        • Data Process
        • Object/File
          • StoreFile
          • StoreObject
          • RetrieveFile
          • RetrieveObject
          • StoreFileToMiners
          • RetrieveFileFromMiners
        • Chain Related
          • Audit
            • QueryChallengeSnapShot
            • QueryCountedClear
            • QueryCountedServiceFailed
            • SubmitIdleProof
            • SubmitServiceProof
            • SubmitVerifyIdleResult
            • SubmitVerifyServiceResult
          • Babe
            • QueryAuthorities
          • Balances
            • QueryInactiveIssuance
            • QueryTotalIssuance
            • TransferToken
          • CessTreasury
            • QueryCurrencyReward
            • QueryEraReward
            • QueryReserveReward
            • QueryRoundReward
          • DeOSS
            • Authorize
            • CancelAuthorize
            • DestroyOss
            • QueryAllOss
            • QueryAuthorityList
            • QueryOss
            • RegisterOss
            • UpdateOss
          • FileBank
            • QueryAllRestoralOrder
            • QueryUserHoldFileList
            • QueryUserFidList
            • QueryDealMap
            • QueryFile
            • QueryRestoralOrder
            • CalculateReport
            • CertIdleSpace
            • ClaimRestoralNoExistOrder
            • ClaimRestoralOrder
            • DeleteFile
            • GenerateRestoralOrder
            • PlaceStorageOrder
            • ReplaceIdleSpace
            • RestoralOrderComplete
            • TransferReport
            • UploadDeclaration
            • TerritoryFileDelivery
          • SchedulerCredit
            • QueryCurrentCounters
          • Session
            • QueryValidators
          • Sminer
            • IncreaseCollateral
            • IncreaseDeclarationSpace
            • MinerExitPrep
            • MinerWithdraw
            • QueryAllMiner
            • QueryAllRestoralTarget
            • QueryCompleteSnapShot
            • QueryCounterForMinerItems
            • QueryExpenders
            • QueryMinerItems
            • QueryPendingReplacements
            • QueryRestoralTarget
            • QueryRewardMap
            • QueryStakingStartBlock
            • ReceiveReward
            • RegisterPoisKey
            • RegnstkAssignStaking
            • RegnstkSminer
            • UpdateBeneficiary
            • UpdateSminerEndPoint
          • Staking
            • QueryAllBonded
            • QueryAllNominators
            • QueryCounterForValidators
            • QueryCurrentEra
            • QueryEraValidatorReward
            • QueryErasRewardPoints
            • QueryErasTotalStake
            • QueryLedger
            • QueryNominatorCount
            • QueryValidatorCommission
            • QueryValidatorsCount
            • QueryeErasStakers
            • QueryeNominators
          • StorageHandler
            • QueryPurchasedSpace
            • QueryTotalIdleSpace
            • QueryTotalServiceSpace
            • QueryUnitPrice
            • QueryTerritory
            • QueryConsignment
            • MintTerritory
            • ExpandingTerritory
            • RenewalTerritory
            • ReactivateTerritory
            • TerritoryConsignment
            • CancelConsignment
            • BuyConsignment
            • CancelPurchaseAction
          • System
            • QueryAccountInfo
            • QueryAccountInfoByAccountID
            • QueryBlockNumber
          • Tee
            • QueryAllWorkers
            • QueryEndpoints
            • QueryMasterPubKey
            • QueryWorkerAddedAt
            • QueryWorkers
          • RPC Calls
            • ChainGetBlock
            • ChainGetBlockHash
            • ChainGetFinalizedHead
            • NetListening
            • SystemChain
            • SystemProperties
            • SystemSyncState
            • SystemVersion
        • Toolset
      • Javascript SDK
      • Rust SDK
        • Preface
        • chain
          • Audit
            • Challenge Snapshot
            • Counted Clear
            • Counted Service Failed
            • Submit Idle Space Proof
            • Submit Service Proof
            • Submit Verify Idle Result
            • Submit Verify Service Result
          • File Bank
            • Bucket
            • Clear User List
            • deal Map
            • File
            • Restoral Order
            • User Bucket List
            • User Hold File List
            • Calculate Report
            • Certify Idle Space
            • Claim Restoral Noexist Order
            • Claim Restoral Order
            • Create Bucket
            • Delete Bucket
            • Delete File
            • Generate Restoral Order
            • Replace Idle Space
            • Restoral Order Complete
            • Territory File Delivery
            • Transfer Report
            • Upload Declaration
          • Oss
            • Authority List
            • Oss
            • Authorize
            • Cancel Authorize
            • Destroy
            • Register
            • Update
          • Storage Handler
            • Consignment
            • Pay Order
            • Purchased Space
            • Territory Expired
            • Territory Frozen Counter
            • Territory Frozen
            • Territory
            • Territory Key
            • Total Power
            • Total Space
            • Unit Price
            • Buy Consignment
            • Cancel Consignment
            • Cancel Purchase Action
            • Create Order
            • Expand Territory
            • Mint Territory
            • Reactivate Territory
            • Renew Territory
            • Territory Consignment
            • Territory Grants
            • Territory Rename
    • Smart Contract
      • Issue ERC20
      • Deploy an ink! Smart Contract
      • Deploy a Solidity Smart Contract
      • Build a Proof of Existence dApp (ink!)
      • Build a NFT Marketplace (ink!)
      • Build a Proof of Existence dApp (Solidity)
    • Advanced Guides
      • Substrate and EVM Address Conversion
      • Commonly Used Libs
      • CESS Code Overview
  • 📱CESS Products
    • DeOSS
      • Introduction
      • Technical Highlights
      • Architecture
      • Data Access Process
      • API Description
        • Prerequisites
        • Identity Signature
        • Upload File/Object
        • Range Upload
        • Download File
        • Preview File
        • Delete File
        • View File Metadata
        • View Version
  • 📚References
    • 📚Node Operations
      • Running RPC Node
    • 📚In-depth Technical Features
      • R²S
      • RRC
      • LBSS
      • VRF
    • Data Lifecycle
      • Data Upload
      • Data Download
      • Data Deletion
      • Data Restore
      • Data Audit
    • Distributed Storage
      • Identification
      • Consistency Guarantee
      • Node Discovery
      • Message Protocol
      • Storage Method
    • DePIN
      • The DePIN Portrait
    • AI
      • CESS: The Future of Decentralized Data Infrastructure for the AI-Driven World
      • Decentralized Solutions for AI: How CESS is Shaping a Trusted Future
      • CESS in CES: Insights from Jensen Huang’s CES 2025 Speech and CESS Network’s Role in the AI Era
      • CESS AI Agent Hub: The Intelligent Portal of the AI Times
  • 📖Glossary
Powered by GitBook
On this page
  • Overview
  • Prerequisite
  • Create a Smart Contract
  • Deploy a Smart Contract
  • References

Was this helpful?

Edit on GitHub
  1. Developers
  2. Smart Contract

Deploy an ink! Smart Contract

Last updated 9 months ago

Was this helpful?

Overview

In this tutorial, we will learn how to deploy an on CESS blockchain. ink! is developed by Parity, the implementation team responsible for the Polkadot Network, and is compiled into Wasm code for execution. It supports running in the WebAssembly Virtual Machine (Wasm VM), and Rust developers can use their already-familiar toolchain to develop smart contracts instead of learning a new language and toolchain.

Prerequisite

  • Install the Rust language and cargo. You can also check the .

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Next, install cargo-contract, a CLI tool to help setting up and managing WebAssembly smart contracts written in ink! ().

    # Install an additional component `rust-src`
    rustup component add rust-src
    # Install `cargo-contract`
    cargo install cargo-contract --force --locked cargo-contract
    # Install `dylint`, a linting tool
    cargo install cargo-dylint
  • Verify the installation is successful by running the command:

    cargo contract --help

    This should display the command help messages similar to the following.

    Utilities to develop Wasm smart contracts
    
    Usage: cargo contract <COMMAND>
    
    Commands:
      new          Setup and create a new smart contract project
      build        Compiles the contract, generates metadata, bundles both together in a `<name>.contract` file
      ...

Create a Smart Contract

We will create a new smart contract project using the cargo-contract package downloaded in the previous step. Run the following command:

cargo contract new flipper

This command generates the following directory with three files

flipper
  ∟ .gitignore
  ∟ Cargo.toml
  ∟ lib.rs

Take a peek into Cargo.toml on the contract dependencies and lib.rs on the contract source code.

Next, we will compile the code and run the test cases inside lib.rs to check everything work accordingly.

cd flipper
cargo test

You should see the following output. This means all test cases have passed.

running 2 tests
test flipper::tests::it_works ... ok
test flipper::tests::default_works ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests flipper

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

We can now build the contract code:

cargo contract build

After the build is complete, the output artifacts are stored in target/ink/ directory. There are three key output files:

  • flipper.wasm - the wasm binary.

  • flipper.json - a metadata file containing the contract ABI.

  • flipper.contract - the contract code that bundles the above two files.

You can also make a release build with cargo contract build --release. The release build has optimization settings to make the code run more efficient in the Wasm VM, but the debug build is good enough for now.

Deploy a Smart Contract

  • # Select the appropriate/latest git tag from the git repository
    git clone https://github.com/CESSProject/cess.git --branch v0.7.8-venus
    cd cess
    # The build process will take probably 10 mins depending on your machine spec
    cargo build
    target/debug/cess-node --dev

The node will start running and the console will display something as below.

  • We will use Substrate Contracts UI to deploy and interact with an ink! smart contract, a UI tool developed by Parity. Let's connect Substrate Contracts UI to our local CESS node by:

  • Click Upload a new contract.

  • In the next screen,

    • In Account select box, select alice to deploy the contract from Alice

    • Give the Contract Name the value Flipper Contract, and

    • Drag or open the file target/ink/flipper.contract in the Upload Contract Bundle.

    You should see the contract metadata after choosing the right contract file. Then click Next.

  • Here, note that the contract code upload and instantiation are separated into two steps. In CESS chain you can have one copy of the smart contract code and multiple instances of that smart contract with different initialization configurations, thus saving blockchain space and encouraging code reuse. For example, multiple ERC20 tokens can reuse the same contract code with different units, logos, and symbols.

    In this screen, we are combining code upload and contract instantiation in one step.

    • Deployment Constructor: select new(initValue: bool)

    • initValue: bool: select false

    • Leave the remaining setting unchanged, and click Next

  • In the next screen, confirm everything looks good and click Upload and Instantiate.

  • You have successfully instantiated a sample flipper contract in this screen.

    Try interact with the flipper contract by reading the value from the smart contract and issue a transaction to it!

References

You can also use one of the .

Run a local in development mode. Perform the following commands to clone CESS node source code, compile it, and run a local node.

Note: Building CESS requires Protocol Buffer version 3.25 or later. Please follow the protocol buffer installation instructions provided .

.

💻
ink! Smart Contract
official guide
GitHub repo
sample ink! smart contract codes here
CESS node
here
https://contracts-ui.substrate.io/?rpc=ws://127.0.0.1:9944
ink! official documentation
CESS node repo
ink! examples repo
Substrate Contracts UI repo
CESS Node Console
Substrate Contract UI
Upload Contract Bundle
Upload Instantiate 01
Upload Instantiate 02
Contract Instantiate Successfully