Skip to content

Commit

Permalink
docs: add instruction for uploading contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
mennatnaga committed Oct 31, 2023
1 parent 127335b commit 360ed95
Showing 1 changed file with 122 additions and 1 deletion.
123 changes: 122 additions & 1 deletion DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Developing


## Environment set up

- Install [rustup][1]. Once installed, make sure you have the wasm32 target:

```bash
rustup default stable
rustup update stable
rustup target add wasm32-unknown-unknown
```

- Install [Docker][2]

- Install [seda-chaind][3]

## Compiling and running tests

```sh
Expand All @@ -10,7 +25,23 @@ cargo wasm
RUST_BACKTRACE=1 cargo unit-test

# auto-generate json schema
cargo schema
cargo schema -p data-requests
cargo schema -p proxy
cargo schema -p staking
```

## Linting

`rustfmt` is used to format any Rust source code:

```bash
cargo +nightly fmt
```

`clippy` is used as a linting tool:

```bash
cargo clippy
```

## Preparing the Wasm bytecode for production
Expand Down Expand Up @@ -50,3 +81,93 @@ This produces an `artifacts` directory including a WASM binary for each contract
This project utilizes [`cargo-crev`](https://github.com/crev-dev/cargo-crev), a language and ecosystem agnostic, distributed code review system. For use, [see the Getting Started guide](https://github.com/crev-dev/cargo-crev/blob/master/cargo-crev/src/doc/getting_started.md).

Additionally, one may use [`cosmwasm-verify`](https://github.com/CosmWasm/cosmwasm-verify) to reproduce the build for verification. See the repository link for use.





## Uploading contracts and setting up cross-dependencies:

- Upload Proxy contract
```bash
1) OUTPUT="$(seda-chaind tx wasm store ./artifacts/proxy_contract.wasm --node $RPC_URL --from $DEV_ACCOUNT --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json --chain-id seda-devnet)"
2) TXHASH=$(echo $OUTPUT | jq -r '.txhash')
3) echo "Proxy Store transaction is $TXHASH"
4) OUTPUT="$(seda-chaind query tx $TXHASH --node $RPC_URL --output json)"
5) PROXY_CODE_ID=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value')
6) echo "Proxy Code ID is $PROXY_CODE_ID"
```


- Instantiate Proxy:
```bash
1) OUTPUT=$(seda-chaind tx wasm instantiate $PROXY_CODE_ID '{"token":"aseda"}' --no-admin --from $DEV_ACCOUNT --node $RPC_URL --label proxy$PROXY_CODE_ID --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json --chain-id seda-devnet)
2) TXHASH=$(echo "$OUTPUT" | jq -r '.txhash')
3) echo "Proxy Instantiate transaction is $TXHASH"
4) OUTPUT="$(seda-chaind query tx $TXHASH --node $RPC_URL --output json)"
5) PROXY_CONTRACT_ADDRESS=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="instantiate") | .attributes[] | select(.key=="_contract_address") | .value')
6) echo "Proxy Contract address is $PROXY_CONTRACT_ADDRESS"
```

- upload DataRequests contract:
```bash
1) OUTPUT="$(seda-chaind tx wasm store artifacts/data_requests.wasm --node $RPC_URL --from $DEV_ACCOUNT --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json --chain-id seda-devnet)"
2) TXHASH=$(echo $OUTPUT | jq -r '.txhash')
3) echo "DataRequests Store transaction is $TXHASH"
4) OUTPUT="$(seda-chaind query tx $dr_store_tx_hash --node $RPC_URL --output json)"
5) DRs_CODE_ID=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value')
6) echo "DataRequests Code ID is $DRs_CODE_ID"
```

- Instantiate DataRequests:

```bash
1) OUTPUT=$(seda-chaind tx wasm instantiate $DRs_CODE_ID '{"token":"aseda", "proxy": "'$PROXY_CONTRACT_ADDRESS'" }' --no-admin --from $DEV_ACCOUNT --node $RPC_URL --label dr$DRs_CODE_ID --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json --chain-id seda-devnet)
2) TXHASH=$(echo "$OUTPUT" | jq -r '.txhash')
3) echo "DataRequests Instantiate transaction is $TXHASH"
4) OUTPUT="$(seda-chaind query tx $TXHASH --node $RPC_URL --output json)"
5) DRs_CONTRACT_ADDRESS=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="instantiate") | .attributes[] | select(.key=="_contract_address") | .value')
6) echo "DataRequests Contract address is $DRs_CONTRACT_ADDRESS"
```

- upload Staking contract:
```bash
1) OUTPUT="$(seda-chaind tx wasm store artifacts/staking.wasm --node $RPC_URL --from $DEV_ACCOUNT --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json --chain-id seda-devnet)"
2) TXHASH=$(echo $OUTPUT | jq -r '.txhash')
3) echo "Store transaction is $TXHASH"
4) OUTPUT="$(seda-chaind query tx $TXHASH --node $RPC_URL --output json)"
5) STAKING_CODE_ID=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value')
6) echo "Staking Code ID is $STAKING_CODE_ID"
```


- Instantiate Staking:
```bash
1) OUTPUT=$(seda-chaind tx wasm instantiate $STAKING_CODE_ID '{"token":"aseda", "proxy": "'$PROXY_CONTRACT_ADDRESS'" }' --no-admin --from $DEV_ACCOUNT --node $RPC_URL --label staking$staking_code_id --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json --chain-id seda-devnet)
2) TXHASH=$(echo "$OUTPUT" | jq -r '.txhash')
3) echo "Staking Instantiate transaction is $TXHASH"
4) OUTPUT="$(seda-chaind query tx $TXHASH --node $RPC_URL --output json)"
5) STAKING_CONTRACT_ADDRESS=$(echo "$OUTPUT" | jq -r '.logs[].events[] | select(.type=="instantiate") | .attributes[] | select(.key=="_contract_address") | .value')
6) echo "Staking Contract address is $STAKING_CONTRACT_ADDRESS"
```

- Set DataRequests on Proxy
```bash
1) OUTPUT="$(seda-chaind tx wasm execute $PROXY_CONTRACT_ADDRESS '{"set_data_requests":{"contract": "'$DRs_CONTRACT_ADDRESS'" }}' --from $DEV_ACCOUNT --node $RPC_URL --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json --chain-id seda-devnet)"
2) TXHASH=$(echo "$OUTPUT" | jq -r '.txhash')
3) echo "SetDataRequests transaction is $TXHASH"
```
- Set Staking on Proxy
```bash
1) OUTPUT="$(seda-chaind tx wasm execute $PROXY_CONTRACT_ADDRESS '{"set_staking":{"contract": "'$STAKING_CONTRACT_ADDRESS'" }}' --from $DEV_ACCOUNT --node $RPC_URL --gas-prices 0.1aseda --gas auto --gas-adjustment 1.3 -y --output json --chain-id seda-devnet)"
2) TXHASH=$(echo "$OUTPUT" | jq -r '.txhash')
3) echo "SetStaking transaction is $TXHASH"
```


## License
Contents of this repository are open source under [MIT License](LICENSE).

[1]: https://rustup.rs/
[2]: https://docs.docker.com/get-docker/
[3]: https://github.com/sedaprotocol/seda-chain

0 comments on commit 360ed95

Please sign in to comment.