About project
Smart contract verification ensures the security, reliability, and trustworthiness of dApps and blockchain platforms. With Patron, you can simplify the deployment flow, manage your builds and make the Polkadot ecosystem more secure and transparent.
So, in other words, Patron is an all-in-one contracts platform, which allows you to build and verify ink! smart contracts inside of an isolated environment, explore contract verification details.
Watch the video about Patron to learn more!
Main problem
Our project solves the problem of reproducible and verifiable smart contract builds. We utilize isolated and constrained environments to build your project in a manner, which produces the same code hash for the same source code. By using such reproducible builds for your smart contracts you can improve trust with your users by guaranteeing that the source code that you publish is the same source code that is used to deploy the contract on-chain.
Your deployment entrypoint is provided by the patron deploy command, which encapsulates both build, upload and instantiation phases of your smart contract deployment lifecycle.
Getting started
Patron is created by Brushfam team as unified solution for smart contract verification. First, it provides a developer-oriented CLI that allows to deploy and verify a contract in one step. Patron uses Astar and Aleph Zero networks for deployment. Another part of the project is Patron UI, where you can find smart contracts by their address or hash code and see the data of contracts.
CLI installation
Start using the CLI by installing it using Cargo:
cargo install patron --git https://github.com/brushfam/patron-backend
Using our CLI, you can authenticate and deploy your smart contracts in an instant, with a vastly simplified deploy flow. For deploy purposes, ensure that you have the Rust toolchain installed (the builds themselves are not local, but cargo is used to install and invoke cargo-contract).
Watch the CLI tutorial video !
Authentication
To authenticate, use the auth subcommand, which automatically redirects you to website to sign an authentication message:
patron auth
If you are using a custom server, you can also pass -s and -w flags to provide URLs for the API server and website.
patron auth -s https://api.example.com -w https://example.com
Custom server URLs are later propagated to other commands (such as deploy) automatically.
Build without deploy
You can acquire contract's WASM blob and JSON metadata files without the deployment itself by using the build subcommand which, by default, outputs contract.wasm and contract.json files to the ./target/ink directory.
To build the contract with Patron, you need to create a Deploy.toml file to the root of your project. This file describes cargo-contract version that will be used during the build. Also, you can check this file into your VCS to share the same configuration with your development team.
Deploy.toml
cargo_contract_version = "3.2.0"
After that, you can run the command:
patron build
When the build process is complete, it will return link to the page with verified build session.
Build command also supports building multi-contract projects using the --root flag:
patron build --root accumulator
See --help flag output for more information.
Local verifying
To verify WASM blob use verify subcommand. It will start two build processes – local and remote one.
patron verify
After builds process will finished, it returns result of verification:
Local code hash:
0xce5...
Code hashes are matching.
Deploy
The build process itself is done on a remote server, but the deployment process is done locally to keep your private keys safe and to facilitate possible air-gapped deployments.
First of all, you need to create a Deploy.toml as described in "Build without deploy" section above.
To start the deployment process for locally running development node simply pass the constructor name and secret URI for the private key:
patron deploy new --suri //Alice
or
patron deploy new --suri "private key using mnemonic phrase"
If your contract constructor requires any arguments, simply pass them with the same syntax that you use with the cargo-contract:
patron deploy new --args 123 --suri //Alice
or
patron deploy with_two_args --args 123,false --suri //Alice
Custom node URL can be provided with the --url flag:
patron deploy new --url wss://node.example.com:443 --suri ...
You can also pass arbitrary flags to cargo-contract using -- syntax:
patron deploy new --suri //Alice -- --password 123
To deploy a project where multi-contracts are stored within one workspace use --root flag:
patron deploy new --suri //Alice --root accumulator
To get more information, invoke the deploy command with the --help flag.
Contract caller
Contract pages contain contract caller UI, so that you can interact with smart contracts deployed on Astar or Aleph Zero. For this, you need to be logged in Patron web app. Go to the contract page and find Caller tab. Here you can see contract functions and documentation if it was provided in the code. To call write functions you will need to pay a fee using your wallet.
Take note, you need to build a contract with cargo-contract version that matches the version of pallet contracts of the blockchain (for instance, cargo-contract 3.2.0 is compatible with Aleph Zero network).
Watch
File watch functionality allows you to simplify your build-deploy-interact cycle during the development process with an automatically refreshed contract caller and contract builder invoked on any meaningful file change.
To start watching, provide the constructor name and suri to the watch subcommand:
patron watch new --suri //Alice
It will open the page with the local contract caller. This component will be refreshed after every build created during the watch command process.
Local build with remote verification
You can also utilize cargo-contract's support of verifiable builds to locally build your contract, deploy it on chain and verify it only after the deployment process.
1. Run cargo contract build --verifiable, wait for the build to finish.
2. Deploy your contract on chain.
3. Run patron build to verify your source code remotely.
By using CLI in that manner, you can ensure that the code on chain was produced locally, while still verifying it with Patron.