Compile a Contract
How to Compile CosmWasm Smart Contracts
Last updated
Was this helpful?
How to Compile CosmWasm Smart Contracts
Last updated
Was this helpful?
. This method of compiling the contract will optimize the final build so that it reduces gas consumption.
Example contracts for this can be found at . This repository since multiple contracts are involved in a single repository.
The easiest way is to simply use the . You must run this in the root of the smart contract repository you wish to compile. It will produce an artifacts
directory with <crate_name>.wasm
and contracts.txt
containing the hashes. This is just one file.
By running this in the root of your project, it will compile your contract into an artifacts/ folder. From here you can upload it to chain, collect the store code, and interact with it as you design
For this use-case there is second docker image, which will compile all the contracts/*
folders inside the workspace and do so one-by-one in alphabetical order. It will then add all the generated wasm files to an artifacts
directory with a checksum, just like the basic docker image (same output format).
To compile all contracts in the workspace deterministically, you can run:
NOTE: See the difference with workspace-optimizer vs rust-optimizer in the previous single contract example.\
Sometime you want many contracts to be related and import common functionality. This is exactly the case of . In such a case, we can often not just compile from root, as the compile order is not deterministic and there are feature flags shared among the repos. This has lead to .