Skip to content

Module 7 - Deploying Smart Contract on Router Chain

Router Rust Optimizer

After Building your Smart Contract it is essential to Deploy them. Deployment is done via the .wasm file you get in the target Directory. There are Two ways of Deploying the Contract -

  • Router Station
  • routerd CLI

Before We Upload .wasm file to Chain, we need to ensure the Smallest Output Size Possible, as this will be included in the Body of a Transaction. We also want to have a Reproducible Build Process, so third Parties can Verify that the Uploaded Wasm Code did indeed come from the Claimed Rust Code.

To Solve Both these issues, we have Produced rust-optimizer, a Docker Image to Produce an extremely Small Build Output in a Consistent Manner. The Suggest way to Run it is this -

  • Windows
Terminal window
docker run --rm -v ${pwd}:/code `
--mount type=volume,source="$("$(Split-Path -Path $pwd -Leaf)")_cache",target=/code/target `
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry `
cosmwasm/rust-optimizer:0.12.13e
  • macOS
Terminal window
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.13

Or, if you’re on an arm64 machine (M1/M2 Macs), you should use a Docker Image Built with arm64.

Terminal window
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer-arm64:0.12.13

Deployment via Router Station

figure 4

On Router Station, you can Directly Upload the .wasm file of your Project and Deploy the Contract. Follow the Below Steps -

  • Keep the Funds field blank.

  • Add a Label to your Contract.

  • In the Instantiate Message enter the Value which is present in Brackets of the pub struct InstantiateMsg {} of msg.rs file in your Project.

Now, Click on Upload and Instantiate Button to Deploy the Contract. After doing this, you’ll be able to Query & Execute the Smart Contract on Router Chain.

To view your Transaction on Routescan, Copy the transactionHash and paste it here.

Deployment via CLI