# Hackatom RU Workshop --- ## Intro - Welcome to workshop, this is orkun from confio team. - As you know IBC is here! - And of course CosmWasm supports IBC! For hackatom participants this workshop will teach you the essential skills for solving the task. --- Good news! ts-relayer that is developed by confio is in alpha stage and actually is the back bone of this network and CosmWasm task in hackatom! the topics are we going to cover --- * transfering native tokens between hackatom-ru <-> swap-testnet-2001 (B-harvest network) * transfering cw20 tokens between hackatom-ru <-> swap-testnet-2001 * Quick snippet: how to set these magical relayer connections?? --- ## Environment setup and scripts ### Environment ```bash export HACKATOM_NODE=(--node "https://rpc.cosmwasm.hub.hackatom.org:443") export HACKATOM_TXFLAG=($HACKATOM_NODE --chain-id hackatom-ru --gas-prices 0.025ucosm --gas auto --gas-adjustment 1.3) export SWAP_NODE=(--node "https://dev.bharvest.io:443/rpc") export SWAP_TXFLAG=($SWAP_NODE --chain-id swap-testnet-2001 --gas-prices 0.025uatom --gas auto --gas-adjustment 1.3) ``` ### hackatom ru CosmWasmd (wasmd) - v0.16.0-alpha1 - RPC:https://cosmwasm.hub.hackatom.org/ orhttps://rpc.cosmwasm.hub.hackatom.org/ - REST:https://rest.cosmwasm.hub.hackatom.org/ - gRPC:https://grpc.cosmwasm.hub.hackatom.org/ - Faucet:https://faucet.cosmwasm.hub.hackatom.org/ - Seeds: 76bf227fff683f27781f8f48a2b540f3989a0d17@34.73.135.54:30328,e6d11a288c6778871165921b674735d69bd2f57a@34.73.135.54:30192 faucet request: ``` curl -X POST "https://faucet.cosmwasm.hub.hackatom.org/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"address\": \"wasm1lzwk8pcu60st03lfjn55994znd0fct4tz46yge\", \"coins\": [ \"1000000ucosm\" ]}" ``` #### IBC channels connection-0 ics20-transfer: channel-0 cw20-transfer: channel-1 ### swap-testnet-2001 connection-1 ics20-transfer: channel-0 cw20-transfer: channel-1 rpc: https://dev.bharvest.io/rpc/ rest: https://dev.bharvest.io/rest/ grpc: https://dev.bharvest.io/grpc/ swap exchange :https://swap.bharvest.io/ Faucet request: `http "https://dev.bharvest.io/faucet/?address=cosmos1mx39y47svjmy3v0hj88sxwsgftm80z2hkslnav"` Balances query: `https://dev.bharvest.io/rest/bank/balances/cosmos190wdjvmz4txdk9jxw4e2cljhgh2fwpak40y5dq` ## transferring native tokens between hackatom-ru - To transfer tokens or just any data between chains you need relayer processes. - Fortunately for hackatom we are providing these processes and channels for you so you don't need to set up - In the last section i will sneak peek how to set up a relayer process using ts-relayer, not very much in details very rough/ - Process of transfering tokens between chains is defined by ics20 procotol, and we have a relayer running this. First setup fresh accounts. ```bash wasmd keys add fresh gaiad keys add fresh curl -X POST "https://faucet.cosmwasm.hub.hackatom.org/" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"address\": \"$(wasmd keys show -a fresh)\", \"coins\": [ ```\"1000000ucosm\" ]}" http "https://dev.bharvest.io/faucet/?address=$(gaiad keys show -a fresh)" ``` Execute the transfer *Keep and eye on relayer logs* ```bash wasmd tx ibc-transfer transfer transfer channel-0 $(gaiad keys show -a fresh) 1000ucosm --from $(wasmd keys show -a fresh) $HACKATOM_TXFLAG ``` ## Transfer cw20 tokens Amazing thing is now we can transfer cw20 tokens to another chains like a native token! check [cw20-ics20](https://github.com/CosmWasm/cosmwasm-plus/tree/master/contracts/cw20-ics20) It sends cw20 tokens over ics20 protocol as if tokens are native. Send cw20 tokens to this address: `wasm18vd8fpwxzck93qlwghaj6arh4p7c5n89k7fvsl` ```bash # store cw20 CODE_ID=$(wasmd tx wasm store cw20_base.wasm --from fresh $HACKATOM_TXFLAG -y | jq -r '.logs[0].events[0].attributes[-1].value') ADMIN=$(wasmd keys show -a ibc-test) INIT=$(jq -n --arg admin $(wasmd keys show -a ibc-test) '{"name":"Golden Stars","symbol":"STAR","decimals":2,"initial_balances":[{"address":$admin,"amount":"10000"}],"mint":{"minter":$admin}}') CONTRACT_ADDR=$(wasmd tx wasm instantiate $CODE_ID "$INIT" --label "STAR" --from ibc-test $HACKATOM_TXFLAG | jq -r '.logs[0].events[0].attributes[-1].value') TO_ADDR=$(liquidityd keys show -a ibc-test) ICS_TRANSFER_MSG=$(jq -n --arg to_addr $TO_ADDR '{"channel": "channel-6", "remote_address": $to_addr}' | base64 -w 0) ICS20_CONTRACT_ADDR=wasm18vd8fpwxzck93qlwghaj6arh4p7c5n89k7fvsl SEND_CW20_MSG=$(jq -n --arg ics20_contract_addr $ICS20_CONTRACT_ADDR --arg transfer_msg $ICS_TRANSFER_MSG '{"send": {"amount": "1000", "contract": $ics20_contract_addr, "msg":$transfer_msg}}') wasmd tx wasm execute $CONTRACT_ADDR "$SEND_CW20_MSG" --from ibc-test $HACKATOM_TXFLAG | jq ```