This is a basic template for developing smart contract and web app together. This template is based on cw-template of CosmWasm.
โ ๏ธ This template was tested only in macOS. We will conduct tests in a wider OS.
- Install Docker https://docs.docker.com/get-docker/
- Install Rust https://www.rust-lang.org/tools/install
- Install Node.js https://nodejs.org/ (recommend node lts version (v16). and update to
npm@8
or higher for workspace feature)
This template requires Docker to run LocalTerra, Rust and Cargo to build Smart Contract, and Node.js.
Please refer to the above links and install them.
First, LocalTerra must be running. Please run LocalTerra using docker-compose.
git clone --depth=1 https://github.com/terra-money/localterra
cd localterra
docker-compose up
Start app development
npx terra-templates get smart-contract:basic myapp
cd myapp
npm install
npm run deploy # build contracts, build schema and build contract types
npm run app:start # run web app
# After that, if you have modified the /contracts source codes, run this again
npm run deploy
All commands are organized in npm script. Please check the commands below.
npm run contract:build
This command builds sources in the~/contracts/*
directories to~/target
.npm run contract:schema
This command create~/schema/*/*.json
schema files.npm run contract:types
This command createsapp/src/contract.ts
file using the~/schema/*/*.json
schema files.npm run app:start
This command run the web app.npm run build
This command runsnpm run contract:build
,npm run contract:schema
, andnpm run contract:types
sequentially.npm run deploy
This command runsnpm run build
and deploy*.wasm
files built thereafter to LocalTerra.npm run test
This command runs all the tests in the~/contracts
and~/app
.npm run test:integration
This command runs the integration tests on the~/test
directory.
If you run run app:start
, you can see a new chrome browser with station extension installed.
You can run the chrome browser with the test conditions you want just by modifying this station.config.json
file without having to set the station extension separately for your test.
All scripts in this template were wrote using Google zx. You can modify these script files when you need to modify build or deploy conditions.