@satlayer/cosmwasm-optimizer
v2.4.0
Published
A command-line tool that simplifies the process of optimizing CosmWasm smart contracts for deployment. This tool wraps the official CosmWasm optimizer Docker image, providing an easy-to-use interface for building production-ready WebAssembly (Wasm) binari
Downloads
17
Readme
SatLayer CosmWasm Optimizer
A command-line tool that simplifies the process of optimizing CosmWasm smart contracts for deployment. This tool wraps the official CosmWasm optimizer Docker image, providing an easy-to-use interface for building production-ready WebAssembly (Wasm) binaries.
Features
- Optimizes CosmWasm contracts for minimal size and gas usage
- Generates contract schema files automatically
- Supports both AMD64 and ARM64 architectures
- Provides Docker build caching for faster builds
- Outputs optimized contract as
contract.wasmwith checksums
Installation
npm install -g @satlayer/cosmwasm-optimizerUsage
Basic usage (run in your contract directory):
cosmwasm-optimizerThis will:
- Build your contract using the CosmWasm optimizer Docker image
- Generate schema files
- Output the optimized contract to
./dist/contract.wasm
Options
--root <path>: Specify a different root directory for the contract (default: current directory)--name <name>: Specify a name for the contract (default: directory name)
Example with options:
cosmwasm-optimizer --root ./my-contract --name my-awesome-contractDocker Caching
You can enable Docker build caching by setting the following environment variables:
DOCKER_CACHE_FROM: Registry to pull cache fromDOCKER_CACHE_TO: Registry to push cache to
Example:
export DOCKER_CACHE_FROM=my-registry.com/cosmwasm-cache
export DOCKER_CACHE_TO=my-registry.com/cosmwasm-cache
cosmwasm-optimizerIntegration with npm scripts
Add to your package.json:
{
"scripts": {
"build": "cosmwasm-optimizer"
}
}Then run:
npm run buildOutput
After running the optimizer, you'll find the following files in the ./dist directory:
contract.wasm: The optimized WebAssembly binarychecksums.txt: SHA256 checksums of the binaryschema/: Directory containing JSON schema filesschema.json: Combined schema file
License
MIT
