Smart Contracts Configuration and Tooling

Introduction

We've developed a versatile smart contract management tool known as klever-sc-meta, often abbreviated as sc-meta. This tool adds a layer of meta-programming to conventional smart contract development. It can read and interact with code written by developers.

You can find it on crates.io

crates.io

To install it, simply execute the following command:

cargo install klever-sc-meta --locked

After installation, you can access the CLI documentation by running sc-meta help or sc-meta -h.

ℹ️ Ubuntu users should ensure that the build_essential package is installed on their system.
In the first case, we encoded None as an empty byte array (encoding it as 0x00 is also accepted). In any case, we need to pass it as an explicit argument.
In the second case, the last argument is omitted altogether.

Standalone Tool vs. Contract Tool

What sets this tool apart is that it comes in two flavors: standalone and contract-specific. The standalone tool can be installed as described above, while the contract tool is provided individually for each contract to aid in building.

The contract tool resides in the meta folder under each contract and consists of just three lines of code:

fn main() {
    klever_sc_meta::cli_main::<my_contract_crate::AbiProvider>();
}

These lines are crucial as they establish a connection between the contract tool and the contract code via the ABI.

The contract tool is essential for building contracts because it is the only tool that utilizes the ABI generator, manages the wasm crate, multi-contract configuration, and possesses the knowledge required to build the contract.

Hence, all functionalities dependent on the ABI are incorporated into the contract tool, while other functionalities remain in the standalone tool.

To access the contract meta CLI documentation, navigate to the /meta crate and execute cargo run help or cargo run -- -h.

Contract Functionality

The current contract functionality includes:

  • abi: Generates the contract ABI and nothing else.
  • build: Builds contract(s) for deployment on the blockchain.
  • build-dbg: Builds contract(s) with symbols and WAT.
  • twiggy: Builds contract(s) and generates twiggy reports.
  • clean: Cleans the Rust project and the output folder.
  • update: Updates the Cargo.lock files in all wasm crates.
  • snippets: Generates a snippets project based on the contract ABI.

For a more detailed explanation of the smart contract ABI and individual contract tools based on ABI, please refer to the CLI reference.

Standalone Functionality

The standalone functionality encompasses:

  • info: Provides general information about the contract and libraries located in the targeted directory.
  • all: Invokes the meta crates for all contracts under a given path with specified arguments.
  • new: Creates a new smart contract from a template.
  • templates: Lists the available templates.
  • upgrade: Upgrades a contract to the latest version. Multiple contract crates are allowed.
  • local-deps: Generates a report on the local dependencies of contract crates, including indirect dependencies.

All standalone tools accept an optional --path argument. If not provided, the current directory is used as the default path.

Was this page helpful?