Coder Social home page Coder Social logo

kevin-valerio / cargo-contract Goto Github PK

View Code? Open in Web Editor NEW

This project forked from use-ink/cargo-contract

0.0 0.0 0.0 3.77 MB

Setup and deployment tool for developing Wasm based smart contracts via ink!

License: GNU General Public License v3.0

Rust 99.42% Dockerfile 0.58%

cargo-contract's Introduction

cargo-contract

CI Status Latest Release stack-exchange

squink, the ink! mascotcargo-contract is a CLI tool which helps you develop smart contracts in Parity'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:

  • Find answers to your questions by joining our Stack Exchange community
  • ink! ‒ The main ink! repository with smart contract examples
  • Contracts UI ‒ Frontend for contract deployment and interaction
  • Substrate Contracts Node ‒ Simple Substrate blockchain which includes smart contract functionality

Installation

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.

    • (MacOS) brew install openssl
    • export TOOLCHAIN_VERSION=nightly-2023-12-28
      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.

Installation using Docker Image

If you prefer to use Docker instead we have 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

Verifiable builds

Some block explorers require the Wasm binary to be compiled in the deterministic environment. 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.

Usage

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_contract

Create 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 build

Compile the contract into optimized WebAssembly bytecode, 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 check

Check that the code builds as WebAssembly. This command does not output any <name>.contract artifact to the target/ directory.

cargo contract upload

Upload a contract to a pallet-contracts enabled chain. See extrinsics.

cargo contract instantiate

Create an instance of a contract on chain. See extrinsics.

cargo contract call

Invoke a message on an existing contract on chain. See extrinsics.

cargo contract encode

Encodes a contract's input calls and their arguments

cargo contract decode

Decode 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 remove

Remove a contract from a pallet-contracts enabled chain. See extrinsics.

cargo contract info

Fetch and display contract information of a contract on chain. See info.

cargo contract verify

Verify that a given contract binary matches the build result of the specified workspace

cargo contract schema-generate

Generate schema and print it to STDOUT.

cargo contract verify-schema

Verify a metadata file or a contract bundle containing metadata against the schema file.

cargo contract storage

Fetch and display the storage of a contract on chain.

cargo contract rpc

Invoke an RPC call to the node. See rpc.

Publishing

In order to publish a new version of cargo-contract:

  • Bump all crate versions, we move them in lockstep.
  • Execute cargo update to update Cargo.lock.
  • Make sure your PR is approved by one or more core developers.
  • Publish metadataanalyzetranscodebuildextrinsicscargo-contract.
  • Merge you PR and push a tag vX.X with your version number: git tag -s vX.X.X && git push origin vX.X.X.
  • Create a GitHub release with the changelog entries.

License

The entire code within this repository is licensed under the GPLv3.

Please contact us if you have questions about the licensing of our products.

cargo-contract's People

Contributors

dependabot[bot] avatar ascjones avatar cmichi avatar robbepop avatar smiasojed avatar athei avatar hcastano avatar brson avatar tripleight avatar honeywest avatar rcny avatar alvicsam avatar lean-apple avatar xgreenx avatar jubnzv avatar sergejparity avatar xermicus avatar koushiro avatar alexd10s avatar agryaznov avatar trace-andreason avatar tareknaser avatar nuke-web3 avatar pepyakin avatar stefie avatar shawntabrizi avatar austinabell avatar statictype avatar jasl avatar kvinwang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.