To Prashant
====
1. Learn about ICON blockchain and smart contracts on icon [here](https://docs.icon.community/icon-stack/smart-contracts)
2. Learn what a cosmos blockchain is.
3. Learn about Archway chain.
### Prerequisities
- Install golang
You don't need to write smart contracts as of now, that'll come later.
- `goloop`: A cli tool that you use to interact with icon blockchain.
```sh
go install github.com/icon-project/goloop/cmd/goloop@latest
goloop -h
```
- `archwayd`: A cli tool you can use to interact with archway chain.
```sh
cd /tmp
wget https://github.com/archway-network/archway/releases/download/v4.0.2/archwayd_linux_amd64
sudo mv archwayd_linux_amd64 /usr/local/bin/archwayd
archwayd -h
```
In solidity, you compile the contract. It generates abi and such. And you deploy the contract using the bytecode.
In ICON, for java smart contracts, when you compile them, you get `jar` file.
In Archway/Cosmos, for rustsmart contracts, when you compile them, you get `wasm` file.
Provided you have the jarFile and arguments for constructor, you can deploy the contracts on ICON
Provided you have the wasm and arguments for constructor, you can deploy the contracts on Archway.
### Testnet Informations:
1. Archway
- Constantine Testnet
- Faucet: Archway Discord
1. ICON
- Faucets: [here](https://faucet.iconosphere.io)
- Berlin Testnet
- Lisbon Testnet
### Wallets
Wallet addresses are different than evm based chains.
1. Archway
```sh
archwayd keys -h
# archwayd keys list
# archwayd keys create myWallet
# Stores the key somewhere, but you can access it easily
```
2. Icon
```sh
goloop ks -h
# goloop ks gen -o myWallet.json -p myPassword
# Creates a json file
```
---
### Contract deploy guide:
- **Archway**:
Deploy guide [here](https://docs.archway.io/developers/guides/my-first-dapp/deploy)
> Note: we use archwayd cli, not archway cli.
You can actually go through [this](https://docs.archway.io/developers/guides/my-first-dapp/start) entire section to get more understanding of the contracts on archway
If you just want to deploy wasm contracts, then get a wasm file.
```sh
wget https://github.com/icon-project/xcall-multi/releases/download/v1.1.0/cw_xcall_0.2.0.wasm
```
Then, from the deploy section, we need to first store the contract, and then initialize it.
The wasm file is generated from [this](https://github.com/icon-project/xcall-multi/tree/v1.1.0/contracts/cosmwasm-vm/cw-xcall/src) contract.
This is the constructor arguments. [here](https://github.com/icon-project/xcall-multi/blob/e95a4f894de1c169abd0d9b68d0169ec7d5f958f/contracts/cosmwasm-vm/cw-xcall/src/msg.rs#L5)
So, we can deploy the contract in 2 commands as:
```sh
archwayd tx wasm store cw_xcall_0.2.0.wasm --from myWallet --node https://rpc.constantine.archway.tech:443 --chain-id constantine-3 --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node 'https://rpc.constantine.archway.tech:443' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.4
```
This command gives a txn hash, search for it in the archway tracker. Note, you get a field codeId here.
```sh
export initialize_args="{\"network_id\":\"myNetwork\",\"denom\":\"aarch\"}"
archwayd tx wasm instantiate ${code_id} $initialize_args --from my-wallet --node https://rpc.constantine.archway.tech:443 --chain-id constantine-3 --label my_first-contract --admin none --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node 'https://rpc.constantine.archway.tech:443' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.3
```
- **Icon**:
Deploy command [here](https://github.com/icon-project/goloop/blob/master/doc/goloop_cli.md#goloop-rpc-sendtx-deploy)
Example:
this is the contract that we want to deploy [link](https://github.com/icon-project/xcall-multi/blob/main/contracts/javascore/xcall/src/main/java/foundation/icon/xcall/CallServiceImpl.java)
check the constructor args for the contract
```java
public CallServiceImpl(String networkId) {
// code
}
```
Now, you can deploy the contract as:
```sh
# get a jarFile from somewhere
wget https://github.com/icon-project/xcall-multi/releases/download/v1.0.0/xcall-0.1.0-optimized.jar
goloop rpc sendtx deploy xcall-0.1.0-optimized.jar \
--content_type application/java \
--uri https://berlin.net.solidwallet.io/api/v3 \
--nid 7 \
--step_limit 100000000000 \
--to cx0000000000000000000000000000000000000000 \
--param networkId=myNetwork \
--key_store ~/keystore/myWallet.json \
--key_password myPassword
```
When you run this command, it gives a transaction hash.
Search for the txn hash on the berlin tracker [here](https://tracker.berlin.icon.community/)
Check what the flags of this command mean from the link above.