diff --git a/examples/hello/scripts/localnet.sh b/examples/hello/scripts/localnet.sh new file mode 100755 index 0000000..62190af --- /dev/null +++ b/examples/hello/scripts/localnet.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e +set -x + +if [ "$1" = "start" ]; then npx hardhat localnet --exit-on-error & sleep 10; fi + +echo -e "\nšŸš€ Compiling contracts..." +npx hardhat compile --force --quiet + +GATEWAY_ETHEREUM=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="ethereum") | .address' localnet.json) +GATEWAY_ZETACHAIN=$(jq -r '.addresses[] | select(.type=="gatewayZEVM" and .chain=="zetachain") | .address' localnet.json) + +CONTRACT_ZETACHAIN=$(npx hardhat deploy --name Universal --network localhost --gateway "$GATEWAY_ZETACHAIN" --json | jq -r '.contractAddress') +echo -e "\nšŸš€ Deployed contract on ZetaChain: $CONTRACT_ZETACHAIN" + +npx hardhat evm-call \ + --gateway-evm "$GATEWAY_ETHEREUM" \ + --receiver "$CONTRACT_ZETACHAIN" \ + --network localhost \ + --types '["string"]' alice + +npx hardhat localnet-check + +if [ "$1" = "start" ]; then npx hardhat localnet-stop; fi \ No newline at end of file diff --git a/examples/nft/scripts/localnet.sh b/examples/nft/scripts/localnet.sh new file mode 100755 index 0000000..2da2baf --- /dev/null +++ b/examples/nft/scripts/localnet.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -e +set -x + +if [ "$1" = "start" ]; then npx hardhat localnet --exit-on-error & sleep 10; fi + +function balance() { + local ZETACHAIN=$(cast call "$CONTRACT_ZETACHAIN" "balanceOf(address)(uint256)" "$SENDER") + local ETHEREUM=$(cast call "$CONTRACT_ETHEREUM" "balanceOf(address)(uint256)" "$SENDER") + local BNB=$(cast call "$CONTRACT_BNB" "balanceOf(address)(uint256)" "$SENDER") + echo -e "\nšŸ–¼ļø NFT Balance" + echo "---------------------------------------------" + echo "šŸŸ¢ ZetaChain: $ZETACHAIN" + echo "šŸ”µ Ethereum: $ETHEREUM" + echo "šŸŸ” BNB Chain: $BNB" + echo "---------------------------------------------" +} + +echo -e "\nšŸš€ Compiling contracts..." +npx hardhat compile --force --quiet + +ZRC20_ETHEREUM=$(jq -r '.addresses[] | select(.type=="ZRC-20 ETH on 5") | .address' localnet.json) +ZRC20_BNB=$(jq -r '.addresses[] | select(.type=="ZRC-20 BNB on 97") | .address' localnet.json) +GATEWAY_ETHEREUM=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="ethereum") | .address' localnet.json) +GATEWAY_BNB=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="bnb") | .address' localnet.json) +SENDER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + +CONTRACT_ZETACHAIN=$(npx hardhat deploy --network localhost --gateway 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 --system-contract 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 --json --gas-limit 1000000 | jq -r '.contractAddress') +echo -e "\nšŸš€ Deployed NFT contract on ZetaChain: $CONTRACT_ZETACHAIN" + +CONTRACT_ETHEREUM=$(npx hardhat deploy --name Connected --json --network localhost --gas-limit 1000000 --gateway "$GATEWAY_ETHEREUM" | jq -r '.contractAddress') +echo -e "šŸš€ Deployed NFT contract on Ethereum: $CONTRACT_ETHEREUM" + +CONTRACT_BNB=$(npx hardhat deploy --name Connected --json --network localhost --gas-limit 1000000 --gateway "$GATEWAY_BNB" | jq -r '.contractAddress') +echo -e "šŸš€ Deployed NFT contract on BNB chain: $CONTRACT_BNB" + +echo -e "\nšŸ“® User Address: $SENDER" + +echo -e "\nšŸ”— Setting counterparty contracts..." +npx hardhat connected-set-counterparty --network localhost --contract "$CONTRACT_ETHEREUM" --counterparty "$CONTRACT_ZETACHAIN" --json &>/dev/null +npx hardhat connected-set-counterparty --network localhost --contract "$CONTRACT_BNB" --counterparty "$CONTRACT_ZETACHAIN" --json &>/dev/null +npx hardhat universal-set-counterparty --network localhost --contract "$CONTRACT_ZETACHAIN" --counterparty "$CONTRACT_ETHEREUM" --zrc20 "$ZRC20_ETHEREUM" --json &>/dev/null +npx hardhat universal-set-counterparty --network localhost --contract "$CONTRACT_ZETACHAIN" --counterparty "$CONTRACT_BNB" --zrc20 "$ZRC20_BNB" --json &>/dev/null + +npx hardhat localnet-check +balance + +NFT_ID=$(npx hardhat mint --network localhost --json --contract "$CONTRACT_ZETACHAIN" --token-uri https://example.com/nft/metadata/1 | jq -r '.tokenId') +echo -e "\nMinted NFT with ID: $NFT_ID on ZetaChain." + +npx hardhat localnet-check +balance + +echo -e "\nTransferring NFT: ZetaChain ā†’ Ethereum..." +npx hardhat transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_ZETACHAIN" --to "$ZRC20_ETHEREUM" + +npx hardhat localnet-check +balance + +echo -e "\nTransferring NFT: Ethereum ā†’ BNB..." +npx hardhat transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_ETHEREUM" --to "$ZRC20_BNB" --gas-amount 0.1 + +npx hardhat localnet-check +balance + +echo -e "\nTransferring NFT: BNB ā†’ ZetaChain..." +npx hardhat transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_BNB" + +npx hardhat localnet-check +balance + +if [ "$1" = "start" ]; then npx hardhat localnet-stop; fi \ No newline at end of file diff --git a/examples/swap/scripts/localnet.sh b/examples/swap/scripts/localnet.sh new file mode 100755 index 0000000..9aeacca --- /dev/null +++ b/examples/swap/scripts/localnet.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +if [ "$1" = "start" ]; then npx hardhat localnet --exit-on-error & sleep 10; fi + +echo -e "\nšŸš€ Compiling contracts..." +npx hardhat compile --force --quiet + +ZRC20_ETHEREUM=$(jq -r '.addresses[] | select(.type=="ZRC-20 ETH on 5") | .address' localnet.json) +ZRC20_USDC=$(jq -r '.addresses[] | select(.type=="ZRC-20 USDC on 97") | .address' localnet.json) +GATEWAY_ETHEREUM=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="ethereum") | .address' localnet.json) +GATEWAY_ZETACHAIN=$(jq -r '.addresses[] | select(.type=="gatewayZEVM" and .chain=="zetachain") | .address' localnet.json) +SENDER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + +CONTRACT_ZETACHAIN=$(npx hardhat deploy --name Swap --network localhost --gateway "$GATEWAY_ZETACHAIN" --json | jq -r '.contractAddress') +echo -e "\nšŸš€ Deployed contract on ZetaChain: $CONTRACT_ZETACHAIN" + +npx hardhat swap-from-evm \ + --network localhost \ + --receiver "$CONTRACT_ZETACHAIN" \ + --amount 1 \ + --target "$ZRC20_USDC" \ + --recipient "$SENDER" + +if [ "$1" = "start" ]; then npx hardhat localnet-stop; fi \ No newline at end of file diff --git a/examples/token/scripts/localnet.sh b/examples/token/scripts/localnet.sh new file mode 100755 index 0000000..36ee1c2 --- /dev/null +++ b/examples/token/scripts/localnet.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -e + +if [ "$1" = "start" ]; then npx hardhat localnet --exit-on-error & sleep 10; fi + +function balance() { + echo -e "\nšŸ–¼ļø Balance" + echo "---------------------------------------------" + local ZETACHAIN=$(cast call "$CONTRACT_ZETACHAIN" "balanceOf(address)(uint256)" "$SENDER") + local ETHEREUM=$(cast call "$CONTRACT_ETHEREUM" "balanceOf(address)(uint256)" "$SENDER") + local BNB=$(cast call "$CONTRACT_BNB" "balanceOf(address)(uint256)" "$SENDER") + echo "šŸŸ¢ ZetaChain: $ZETACHAIN" + echo "šŸ”µ EVM Chain: $ETHEREUM" + echo "šŸŸ” BNB Chain: $BNB" + echo "---------------------------------------------" +} + +echo -e "\nšŸš€ Compiling contracts..." +npx hardhat compile --force --quiet + +ZRC20_ETHEREUM=$(jq -r '.addresses[] | select(.type=="ZRC-20 ETH on 5") | .address' localnet.json) +ZRC20_BNB=$(jq -r '.addresses[] | select(.type=="ZRC-20 BNB on 97") | .address' localnet.json) +GATEWAY_ETHEREUM=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="ethereum") | .address' localnet.json) +GATEWAY_BNB=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="bnb") | .address' localnet.json) +SENDER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + + +CONTRACT_ZETACHAIN=$(npx hardhat deploy --network localhost --gas-limit 700000 --json | jq -r '.contractAddress') +echo -e "\nšŸš€ Deployed contract on ZetaChain: $CONTRACT_ZETACHAIN" + +CONTRACT_ETHEREUM=$(npx hardhat deploy --name Connected --json --network localhost --gateway "$GATEWAY_ETHEREUM" | jq -r '.contractAddress') +echo -e "šŸš€ Deployed contract on EVM chain: $CONTRACT_ETHEREUM" + +CONTRACT_BNB=$(npx hardhat deploy --name Connected --json --network localhost --gateway "$GATEWAY_BNB" | jq -r '.contractAddress') +echo -e "šŸš€ Deployed contract on BNB chain: $CONTRACT_BNB" + +echo -e "\nšŸ“® User Address: $SENDER" + +echo -e "\nšŸ”— Setting counterparty contracts..." +npx hardhat connected-set-counterparty --network localhost --contract "$CONTRACT_ETHEREUM" --counterparty "$CONTRACT_ZETACHAIN" --json &>/dev/null +npx hardhat connected-set-counterparty --network localhost --contract "$CONTRACT_BNB" --counterparty "$CONTRACT_ZETACHAIN" --json &>/dev/null +npx hardhat universal-set-counterparty --network localhost --contract "$CONTRACT_ZETACHAIN" --counterparty "$CONTRACT_ETHEREUM" --zrc20 "$ZRC20_ETHEREUM" --json &>/dev/null +npx hardhat universal-set-counterparty --network localhost --contract "$CONTRACT_ZETACHAIN" --counterparty "$CONTRACT_BNB" --zrc20 "$ZRC20_BNB" --json &>/dev/null + +npx hardhat localnet-check +balance + +TOKEN=$(npx hardhat mint --network localhost --json --contract "$CONTRACT_ZETACHAIN" --to "$SENDER" --amount 10 | jq -r '.contractAddress') +echo -e "\nMinted tokens: $TOKEN on ZetaChain." + +npx hardhat localnet-check +balance + +echo -e "\nTransferring token: ZetaChain ā†’ Ethereum..." +npx hardhat transfer --network localhost --json --amount 10 --from "$CONTRACT_ZETACHAIN" --to "$ZRC20_ETHEREUM" + +npx hardhat localnet-check +balance + +echo -e "\nTransferring token: Ethereum ā†’ BNB..." +npx hardhat transfer --network localhost --json --amount 10 --from "$CONTRACT_ETHEREUM" --to "$ZRC20_BNB" --gas-amount 1 + +npx hardhat localnet-check +balance + +echo -e "\nTransferring token: BNB ā†’ ZetaChain..." +npx hardhat transfer --network localhost --json --amount 10 --from "$CONTRACT_BNB" + +npx hardhat localnet-check +balance + +if [ "$1" = "start" ]; then npx hardhat localnet-stop; fi \ No newline at end of file