2023-11-29 16:34:24 +00:00
|
|
|
# Bisenzone CosmWasm MVP
|
|
|
|
|
|
|
|
CosmWasm smart contracts used in the Bisenzone MVP.
|
|
|
|
|
|
|
|
## Testing instructions
|
|
|
|
|
|
|
|
* Deploy the smart contract on a local wasmd instance
|
|
|
|
(see [Obligation Clearing Mvp: Local setup](https://github.com/informalsystems/obligation-clearing-mvp#local-setup))
|
|
|
|
* Should normally be as simple as running the following scripts ->
|
|
|
|
```bash
|
|
|
|
# terminal-1
|
|
|
|
./scripts/keygen.sh
|
|
|
|
./scripts/init-node.sh
|
|
|
|
./scripts/run-node.sh
|
|
|
|
```
|
|
|
|
```bash
|
|
|
|
# terminal-2
|
|
|
|
./scripts/build-contract.sh
|
|
|
|
./scripts/deploy-contract.sh artifacts/cw_mtcs.wasm
|
|
|
|
```
|
|
|
|
* Set contract env var (using the output of the `deploy.sh` script) -
|
2023-11-14 15:30:48 +00:00
|
|
|
|
|
|
|
```
|
2023-11-29 16:34:24 +00:00
|
|
|
export CONTRACT="wasm13we0myxwzlpx8l5ark8elw5gj5d59dl6cjkzmt80c5q5cv5rt54qhmta7s"
|
2023-11-14 15:30:48 +00:00
|
|
|
```
|
|
|
|
|
2023-11-29 16:34:24 +00:00
|
|
|
* Upload a cycle of obligations -
|
2023-11-14 15:30:48 +00:00
|
|
|
|
|
|
|
```
|
2023-11-29 16:34:24 +00:00
|
|
|
export EXECUTE='{
|
|
|
|
"upload_obligation": {
|
|
|
|
"creditor": "wasm19u72czh0w4jraan8esalv48nrwemh8kgax69yw",
|
|
|
|
"amount": "100",
|
|
|
|
"memo": "alice -> bob"
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
wasmd tx wasm execute "$CONTRACT" "$EXECUTE" --from alice --chain-id testing -y
|
|
|
|
|
|
|
|
export EXECUTE='{
|
|
|
|
"upload_obligation": {
|
|
|
|
"creditor": "wasm12r9t5wmre89rwakr0e5nyhfmaf4kdleyltsm9f",
|
|
|
|
"amount": "80",
|
|
|
|
"memo": "bob -> charlie"
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
wasmd tx wasm execute "$CONTRACT" "$EXECUTE" --from bob --chain-id testing -y
|
|
|
|
|
|
|
|
export EXECUTE='{
|
|
|
|
"upload_obligation": {
|
|
|
|
"creditor": "wasm19xlctyn7ha6pqg7pk9lnk8y60rk8646dm86qgv",
|
|
|
|
"amount": "70",
|
|
|
|
"memo": "charlie -> alice"
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
wasmd tx wasm execute "$CONTRACT" "$EXECUTE" --from charlie --chain-id testing -y
|
2023-11-14 15:30:48 +00:00
|
|
|
```
|
|
|
|
|
2023-11-29 16:34:24 +00:00
|
|
|
* Clear cycle -
|
2023-11-14 15:30:48 +00:00
|
|
|
|
2023-11-29 16:34:24 +00:00
|
|
|
```
|
|
|
|
export EXECUTE='{
|
|
|
|
"apply_cycle": {
|
|
|
|
"path": ["wasm19xlctyn7ha6pqg7pk9lnk8y60rk8646dm86qgv", "wasm19u72czh0w4jraan8esalv48nrwemh8kgax69yw", "wasm12r9t5wmre89rwakr0e5nyhfmaf4kdleyltsm9f", "wasm19xlctyn7ha6pqg7pk9lnk8y60rk8646dm86qgv"],
|
|
|
|
"amount": "70"
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
wasmd tx wasm execute "$CONTRACT" "$EXECUTE" --from alice --chain-id testing -y
|
|
|
|
```
|
2023-11-14 15:30:48 +00:00
|
|
|
|
2023-11-29 16:34:24 +00:00
|
|
|
* Query obligations -
|
2023-11-14 15:30:48 +00:00
|
|
|
|
2023-11-29 16:34:24 +00:00
|
|
|
```
|
|
|
|
* wasmd query wasm contract-state smart "$CONTRACT" '{
|
|
|
|
"get_obligations": {
|
|
|
|
"creditor": "wasm19u72czh0w4jraan8esalv48nrwemh8kgax69yw"
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
```
|
2023-11-14 15:30:48 +00:00
|
|
|
|
2023-11-29 16:34:24 +00:00
|
|
|
* Check balance of the solver (to confirm increase in karma) -
|
2023-11-14 15:30:48 +00:00
|
|
|
|
2023-11-29 16:34:24 +00:00
|
|
|
```
|
|
|
|
wasmd query wasm contract-state smart "$CONTRACT" '{
|
|
|
|
"balance": {
|
|
|
|
"address": "wasm19xlctyn7ha6pqg7pk9lnk8y60rk8646dm86qgv"
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
```
|