11 releases

0.1.13 Nov 27, 2024
0.1.12 Nov 8, 2024
0.1.9 Oct 29, 2024
0.1.7 Sep 6, 2024
0.1.6 Aug 28, 2024

#6 in #clique

Download history 149/week @ 2024-08-26 162/week @ 2024-09-02 2/week @ 2024-09-16 8/week @ 2024-09-23 1/week @ 2024-10-07 3/week @ 2024-10-14 364/week @ 2024-10-28 150/week @ 2024-11-04 14/week @ 2024-11-11 8/week @ 2024-11-18 138/week @ 2024-11-25 26/week @ 2024-12-09

173 downloads per month

Apache-2.0

39KB
622 lines

clique-cli

The Clique Command Line Interface (Clique CLI) is an open-source tool that enables you to develop, build, test, and deploy your tasks to the Clique Network.

Installation

If you have installed the Rust toolchain already, you can get our pre-built executable from cargo.

$ cargo install clique-cli

Build from Source

You can also build the executable yourself with the following guidelines.

Pre-requisites

  • Rust-toolchain

Step-by-step Guide

Clone the Clique CLI from GitHub

$ git clone https://github.com/CliqueOfficial/clique-protocol-sdk.git

Build the Binary with Cargo

$ cargo build --release --bin clique

Install the Built Executable to System

# Install the binary locally (recommended)
$ cp target/release/clique ~/.local/bin/
# Or if you want to install it globally
$ sudo cp target/release/clique /usr/bin/

Make sure ~/.local/bin is includes in $PATH environment variable.

Develop Task

Initialize from Template

To initialize a repository, use the following command:

$ clique init --template evm

This command will create a project that outputs a Clique Task Manifest file containing a corresponding EVM bytecode (note that the bytecode format is different based on the VM you specify -- we plan to support WASM, RISC V, etc in the future).

How to Use

Before initialization, it is essential to establish an empty directory to serve as your workspace.

$ mkdir workspace
$ cd workspace
$ clique init --template evm

Project Structure

After initialization, the project structure is as follows:

/workspace
-- contracts
   -- Main.sol
-- manifest.toml
-- foundry.toml
  • /contracts/Main.sol is the primary Solidity smart contract source file. This file contains the core smart contract logic and functionalities within the project.
  • manifest.toml is a clique task metadata written in TOML, including I/O schemas, proof types, and optional code or task sections depending on the task type.
  • foundry.toml is a configuration file specific to the Foundry toolkit. You can use Foundry to compile and test your contracts. Foundry will also be required for the subsequent build phase to compile the contracts.

If you haven't set up the Foundry environment yet, run the following command in your terminal, then follow the onscreen instructions:

curl -L https://foundry.paradigm.xyz | bash

Upon completion of template initialization, you can modify the contract and manifest.toml.

It is important to note that the contract entry point is fixed and must be Main.sol. And the function name must be evaluate. Users can import other contracts into Main.sol.

After modifying the contracts, users should update manifest.toml with new name, input, output, and proof-compability sections according to the changes made to the contracts. The code section should be left empty, as it will be automatically populated by the CLI during build stage.

Build Task

Run the following command to build the developed task.

clique build --type evm

After build, your workspace structure should look like the following:

/workspace
-- contracts
   -- Main.sol
-- tasks
   -- manifest.toml
-- manifest.toml
-- foundry.toml

During the development phase, the developer has modified the contract code and manifest.toml, with the code section in manifest.toml left blank.

In the build phase, we will generate a copy of manifest.toml to tasks/manifest.toml and automatically populate the code section. We utilize the Foundry toolkit to compile the contracts and automatically populate the compiled bytecode into the newly copied manifest.toml.

Test Task (TODO: run test locally)

To test the task without publishing, run the following command:

$ clique test -f manifest.toml

Deploy Task

To deploy the task locally, run the following command.

clique deploy --kernel http://127.0.0.1:8000

To publish the task to the Clique network,

clique deploy --kernel http://kernel-testnet.clique.tech

Dependencies

~68MB
~1.5M SLoC