Skip to content

Deploy Guide

Antonio Yang edited this page Dec 3, 2021 · 9 revisions

Deploy Guide

Building and deploying for sewup projects is easier by cargo sewup cli tool, however you still can get the ewasm binary and deploy with web3js or other client. Also cargo sewup cli tool provide the abi.json generator, you can use web3js to interact with ERC token contracts made with sewup.

Deploy with cargo sewup

In following sections, I will describe that how sewup project deploy on the block chain network, this method is easier and the build will automatically done be fore deployment.

Providing deployment information

Following deploy configure should provide in sewup.toml. Besides, you may optionally change the gas and the gas_price as you need.

[deploy]
url = "http://localhost:8545"
private = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
address = "0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# gas = 5000000  # optional
# gas_price = 1  # optional

Install sewup tool and deploy

Install deploy tool

  1. Install cargo-sewup cargo install cargo-sewup
  2. Provide deploy section in the Cargo.toml of the contract
  3. Deploy cargo sewup
  • If you are using older version cargo-sewup and want to upgrade, please update by following command cargo install cargo-sewup --force

Build with cargo sewup and deploy with other clients

cargo-sewup can build a deployable ewasm without deploy with --build-onlyor -b option . The deployable ewasm will be built as ./target/wasm32-unknown-unknown/release/{contract_name}.deploy.wasm You can read it as binary and deploy with tool you want. Following is the building flow of deployable ewasm.

graph TD

A[cargo sewup --build-only] -->|compile| B(Constructor wasm)
A -->|compile| C(Runtime wasm)
B --> |modified| D(Constructor ewasm)
C --> |modified| E(Runtime ewasm)
D --> |as body part| F[deployable wasm]
E --> |as return part| F
Loading

View build flow

Generate abi.json

It is not required to use sewup be complied with web3.js, and the token apis of sewup are complied with web3.js. You may use following command to generate the abi.json for web.js client. cargo sewup -g or cargo sewup --generate-abi.

Following is the flow for generating the abi.json

graph TD

A[cargo sewup --generate-abi] -->|compile| B(Runtime wasm)
B --> |expand macro and parse handlers in use| C[generator.rs]
C --> |run and print| D[abi.json]
Loading

View abi generating flow