https://github.com/oraichain/cosmwasm-tools
A super fast and cross-platform alternative to rust-optimizer that produces optimized wasm files
https://github.com/oraichain/cosmwasm-tools
typescript
Last synced: 2 months ago
JSON representation
A super fast and cross-platform alternative to rust-optimizer that produces optimized wasm files
- Host: GitHub
- URL: https://github.com/oraichain/cosmwasm-tools
- Owner: oraichain
- Created: 2023-01-04T08:54:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-12T09:16:16.000Z (8 months ago)
- Last Synced: 2025-04-17T02:28:31.551Z (3 months ago)
- Topics: typescript
- Language: TypeScript
- Homepage:
- Size: 757 KB
- Stars: 12
- Watchers: 2
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-cosmwasm - cosmwasm-tools - A super (Tooling / Other Contracts)
README
# Installation
You can install cwtools globally using npm `npm install -g @oraichain/cwtools` or yarn `yarn global add @oraichain/cwtools`
# Usage
Type `cwtools -h`
```bash
cwtools [command]Commands:
cwtools genjs generate JavaScript classes for the contract folders
cwtools gents generate TypeScript classes for the contract folders
cwtools build build a list of contract folders
cwtools wasm wasm commands
cwtools script run custom typescript fileOptions:
-h, --help Show help [boolean]
--version Show version number [boolean]
--env Path to JSON config file [default: ".env"]
--file-input Path to JSON config file```
Cosmwasm commands with encrypted mnemonic
Custom script: `scripts/show_account.ts`
```ts
export default async (argv, common, exports) => {
const { stringToPath } = exports['@cosmjs/crypto'];
const { GasPrice } = exports['@cosmjs/stargate'];
const { SigningCosmWasmClient } = exports['@cosmjs/cosmwasm-stargate'];
const { DirectSecp256k1HdWallet } = exports['@cosmjs/proto-signing'];const prefix = process.env.PREFIX || 'orai';
const mnemonic = argv.ENCRYPTED_MNEMONIC ? common.decryptMnemonic(argv.ENCRYPTED_MNEMONIC) : argv.MNEMONIC;
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
hdPaths: [stringToPath(process.env.HD_PATH)],
prefix
});
const [firstAccount] = await wallet.getAccounts();const client = await SigningCosmWasmClient.connectWithSigner(process.env.RPC_URL, wallet, {
gasPrice: GasPrice.fromString(`${process.env.GAS_PRICES}${prefix}`)
});console.log(firstAccount);
};
``````bash
# generate encrypted mnemonic
cwtools script scripts/show_account.ts# then put it into .env file then run
cwtools wasm -h
```# Experimental build
Turn on all optimization params to save size
`cwtools build contract --cargo='-Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort' --RUSTFLAGS=-Zlocation-detail=none`