This a CosmWasm smart contract that provides the bilateral exchange of provenance
markers
.
make
git clone [email protected]:provenance-io/provenance.git
git clone [email protected]:provenance-io/bilateral-exchange.git
cp bilateral-exchange/examples/bilateral.sh bilateral-exchange/examples/create-base.sh provenance
cd bilateral-exchange
make
cp artifacts/bilateral_exchange.wasm ../provenance
cd ../provenance
./create-base.sh
./bilateral.sh
NOTE: Address bech32 values and other generated params may vary.
-
Configure the following:
- Accounts:
- Asker
- Buyer
- Markers:
- Base
- Quote
- Accounts:
-
Store the
bilateral-exchange
WASM:build/provenanced tx wasm store bilateral_exchange.wasm \ --from validator \ --keyring-backend test \ --home build/run/provenanced \ --chain-id testing \ --gas auto --gas-prices 1905nhash --gas-adjustment 2 \ --broadcast-mode block \ --yes \ --testnet
-
Instantiate the contract, binding the name
bilateral-ex.sc.pb
to the contract address:build/provenanced tx wasm instantiate 1 '{"bind_name":"bilateral-ex.sc","contract_name":"bilateral-ex"}' \ --admin "$(build/provenanced keys show -ta validator --home build/run/provenanced --keyring-backend test)" \ --from validator \ --keyring-backend test \ --home build/run/provenanced \ --chain-id testing \ --label ats-gme-usd \ --gas auto --gas-prices 1905nhash --gas-adjustment 2 \ --broadcast-mode block \ --yes \ --testnet
-
Create an
ask
order:NOTE: Replace
M2
with theask
base marker. ReplaceM1_AMT
andM1_DENOM
with quote markerNOTE++: The json data '{"create_ask":{}}' represents the action and additional data to pass into the smart contract. The actual coin with the transaction is the
--amount
option.build/provenanced tx wasm execute "$(provenanced q name resolve bilateral-ex.sc --testnet | awk '{print $2}')" \ '{"create_ask":{"id":"ask_id", "quote":[{"amount":"M1_AMT", "denom":"M1_DENOM"}]}}' \ --amount M2 \ --from (build/provenanced keys show -ta seller --home build/run/provenanced --keyring-backend test) \ --keyring-backend test \ --home build/run/provenanced \ --chain-id testing \ --gas auto --gas-prices 1905nhash --gas-adjustment 2 \ --broadcast-mode block \ --yes \ --testnet
-
Create a
bid
order:NOTE: Replace
M1
with thebid
quote marker. ReplaceM2_AMT
andM2_DENOM
with base markerNOTE++: The json data '{"create_bid":{}}' represents the action and additional data to pass into the smart contract. The actual coin with the transaction is the
--amount
option.build/provenanced tx wasm execute "$(provenanced q name resolve bilateral-ex.sc --testnet | awk '{print $2}')" \ '{"create_bid":{"id":"bid_id", "base":[{"amount":"M2_AMT", "denom":"M2_DENOM"}]}}' \ --amount M1 \ --from (build/provenanced keys show -ta buyer --home build/run/provenanced --keyring-backend test) \ --keyring-backend test \ --home build/run/provenanced \ --chain-id testing \ --gas auto --gas-prices 1905nhash --gas-adjustment 2 \ --broadcast-mode block \ --yes \ --testnet
-
Match and execute the ask and bid orders.
build/provenanced tx wasm execute "$(provenanced q name resolve bilateral-ex.sc --testnet | awk '{print $2}')" \ '{"execute_match":{"ask_id":"ask_id", "bid_id":"bid_id"}}' \ --from validator \ --keyring-backend test \ --home build/run/provenanced \ --chain-id testing \ --gas auto --gas-prices 1905nhash --gas-adjustment 2 \ --broadcast-mode block \ --yes \ --testnet
Cancel the contract.
build/provenanced tx wasm execute "$(provenanced q name resolve bilateral-ex.sc --testnet | awk '{print $2}')" \
'{"cancel_ask":{"id":"ask_id"}}' \
--from (build/provenanced keys show -ta seller --home build/run/provenanced --keyring-backend test) \
--keyring-backend test \
--home build/run/provenanced \
--chain-id testing \
--gas auto --gas-prices 1905nhash --gas-adjustment 2 \
--broadcast-mode block \
--yes \
--testnet
Query for ask order information:
provenanced query wasm contract-state smart "$(provenanced q name resolve bilateral-ex.sc --testnet | awk '{print $2}')" \
'{"get_ask":{"id":"ask_id"}}' \
--testnet
Query for bid order information:
provenanced query wasm contract-state smart "$(provenanced q name resolve bilateral-ex.sc --testnet | awk '{print $2}')" \
'{"get_bid":{"id":"bid_id"}}' \
--testnet
Query for contract instance information
provenanced query wasm contract-state smart "$(provenanced q name resolve bilateral-ex.sc --testnet | awk '{print $2}')" \
'{"get_contract_info":{}}' \
--testnet