Skip to content

Commit

Permalink
Document contract verification
Browse files Browse the repository at this point in the history
  • Loading branch information
moubctez committed Aug 14, 2024
1 parent d4aab00 commit 27b4fb3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/docs/casper/developers/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This section explains how to interact with a Casper network using the Casper com
| [Undelegating Tokens with the Casper Client](./undelegate.md) | Undelegating tokens from a validator on a Casper network |
| [Sending Deploys to a Network](./sending-transactions.md) | Sending Deploys to a Casper network using the Rust CLI Client |
| [Installing Smart Contracts](./installing-contracts.md) | Steps to install a contract on a Casper network |
| [Verifying contracts using the Casper Client](./verifying-contracts.md) | How to use Smart Contract Verification Service |
| [Querying Global State](./querying-global-state.md) | How to query global state after contract installation |
| [Calling Smart Contracts with the Rust Client](./calling-contracts.md) | Various ways to call a contract's entry-points |
| [Execution Error Codes](./execution-error-codes.md) | Error codes for smart contract execution |
2 changes: 1 addition & 1 deletion source/docs/casper/developers/cli/installing-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This document details the process of installing [Casper smart contracts](../writ
## Prerequisites

- You have a compiled contract (`.wasm` file) to send to a Casper network
- You have installed the [Casper CLI client](../prerequisites.md#installing-the-casper-client-install-casper-clie) to interact with the network
- You have installed the [Casper CLI client](../prerequisites.md#install-casper-client) to interact with the network
- You have a [Casper Account](../prerequisites.md#setting-up-an-account) with a public and secret key pair to initiate the deploy
- You have enough CSPR tokens in your account's main purse to pay for deploys. If you plan to use the Casper Testnet, learn about the [faucet](../../users/csprlive/testnet-faucet.md) to fund your testing account's main purse

Expand Down
35 changes: 35 additions & 0 deletions source/docs/casper/developers/cli/verifying-contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Verifying Contracts
---

import useBaseUrl from '@docusaurus/useBaseUrl';

# Verifying Smart Contracts

This document describes actions needed for smart contract verification using [Casper CLI client](../prerequisites.md#install-casper-client).

## Prerequisites

- You have built and installed a contract

## Verifying contracts using the Casper Client {#verifying-the-contract}

You can use the Casper client's `verify-contract` command to have your contract verified. This command archives your contracts source code and sends it to the verification service. This service performs all the same operations on the provided source that a node does when deploying a smart contract on the blockchain. The resulted binary is then compared byte-by-byte against the contract fetched from the Casper blockchain based on the inputed transaction hash. If they match then the verification is a success.

```bash
casper-client verify-contract --verification-url-basepath <HOST:PORT> <TRANSACTION-HASH> <PATH>
```

1. `verification-url-basepath` - the address of the verification service which will perform the operation, the current two options are: https://staging.codeverifier.casper.network for Testnet and https://codeverifier.casper.network for Mainnet.
2. `<TRANSACTION-HASH>` - unique transaction hash, which is part of the cryptographic security of blockchain technology. It's the output of the put-txn command if the deploy was a success.
3. `<PATH>` - the path to the smart contracts source code. If this argument is omitted the the current working directory will be used.

The prerequisites for the source code are the same as when deploying it on the blockchain:

* source code must be a Rust project as described in The Cargo Book

* there has to be either rust-toolchain or rust-toolchain.toml file, and its contents must define a valid Rust toolchain, as described in The rustup book.

* deployed contract (web-assembly binary) must be stripped off of debugging symbols prior submitting to Casper node. It can be achieved either by specifying strip = "symbols" in Rust project configuration, or by using wasm-strip from wabt package.

If the verification result is a success then users will be able to see that information various websites integrated with the service f.e. on https://staging.casperecosystem.io/check-verification-status/ for Testnet transactions and https://casperecosystem.io/check-verification-status/ for Mainnet transactions. This will also give them the ability to browse through the source code of your smart contract which adds a new layer of transparency and trust.

0 comments on commit 27b4fb3

Please sign in to comment.