Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Call example on localnet #510

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/pages/developers/tutorials/call.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ With localnet running, open a new terminal window to compile and deploy the
```bash
npx hardhat compile --force
npx hardhat deploy --name Universal --network localhost --gateway 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707
npx hardhat deploy --name Connected --json --network localhost --gateway 0x610178dA211FEF7D417bC0e6FeD39F05609AD788
npx hardhat deploy --name Connected --network localhost --gateway 0x610178dA211FEF7D417bC0e6FeD39F05609AD788
```

You should see output indicating the successful deployment of the contracts:
Expand All @@ -404,12 +404,12 @@ You should see output indicating the successful deployment of the contracts:
🔑 Using account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

🚀 Successfully deployed "Universal" contract on localhost.
📜 Contract address: 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB
📜 Contract address: 0xc351628EB244ec633d5f21fBD6621e1a683B1181

🔑 Using account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

🚀 Successfully deployed "Conntected" contract on localhost.
📜 Contract address: 0x9E545E3C0baAB3E08CdfD552C960A1050f373042
🚀 Successfully deployed "Connected" contract on localhost.
📜 Contract address: 0xFD471836031dc5108809D173A067e8486B9047A3
```

**Note**: The deployed contract addresses may differ in your environment.
Expand All @@ -423,8 +423,8 @@ deployment:

```bash
npx hardhat connected-call \
--contract 0x9E545E3C0baAB3E08CdfD552C960A1050f373042 \
--receiver 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB \
--contract 0xFD471836031dc5108809D173A067e8486B9047A3 \
--receiver 0xc351628EB244ec633d5f21fBD6621e1a683B1181 \
--network localhost \
--types '["string"]' alice
```
Expand All @@ -438,8 +438,8 @@ from your deployment:

```bash
npx hardhat universal-call \
--contract 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB \
--receiver 0x9E545E3C0baAB3E08CdfD552C960A1050f373042 \
--contract 0xc351628EB244ec633d5f21fBD6621e1a683B1181 \
--receiver 0xFD471836031dc5108809D173A067e8486B9047A3 \
--zrc20 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe \
--function "hello(string)" \
--network localhost \
Expand All @@ -453,11 +453,12 @@ app, run the following command:

```bash
npx hardhat universal-withdraw-and-call \
--contract 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB \
--receiver 0x9E545E3C0baAB3E08CdfD552C960A1050f373042 \
--zrc20 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c \
--contract 0xc351628EB244ec633d5f21fBD6621e1a683B1181 \
--receiver 0xFD471836031dc5108809D173A067e8486B9047A3 \
--zrc20 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe \
--function "hello(string)" \
--amount 1 \
--call-options-is-arbitrary-call \
--network localhost \
--types '["string"]' hello
```
Expand Down
40 changes: 33 additions & 7 deletions src/pages/developers/tutorials/swap-any.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Once your environment is set up, compile the contract and deploy it to localnet
using the following command:

```
yarn deploy-any:localnet
npx hardhat deploy --name SwapToAnyToken --network localhost --gateway 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 --uniswap-router 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
fadeev marked this conversation as resolved.
Show resolved Hide resolved
```

After deployment, you should see an output similar to this:
Expand All @@ -279,7 +279,7 @@ After deployment, you should see an output similar to this:
🔑 Using account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

🚀 Successfully deployed contract on localhost.
📜 Contract address: 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB
📜 Contract address: 0xc351628EB244ec633d5f21fBD6621e1a683B1181
```

## Swap and Withdraw Tokens to Connected Chain
Expand All @@ -288,7 +288,13 @@ To swap tokens from a connected EVM chain and withdraw them to the destination
chain, use the following command:

```
npx hardhat swap-from-evm --network localhost --receiver 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB --amount 1 --target 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c --recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --withdraw true
npx hardhat swap-from-evm \
--network localhost \
--receiver 0xc351628EB244ec633d5f21fBD6621e1a683B1181 \
--amount 1 \
--target 0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0 \
--recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
--withdraw true
```

- EVM gateway is called with 1 native gas token (ETH) and a message that
Expand All @@ -308,7 +314,13 @@ If you want to swap tokens and keep them on ZetaChain rather than withdrawing
them, set the `withdraw` flag.

```
npx hardhat swap-from-evm --network localhost --receiver 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB --amount 1 --target 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c --recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --withdraw false
npx hardhat swap-from-evm \
--network localhost \
--receiver 0xc351628EB244ec633d5f21fBD6621e1a683B1181 \
--amount 1 \
--target 0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0 \
--recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
--withdraw false
```

In the command above the `withdraw` is `false`, so the target ZRC-20 token will
Expand All @@ -320,7 +332,14 @@ To swap a ZRC-20 token for another ZRC-20 on ZetaChain and withdraw to a
connected chain, run:

```
npx hardhat swap-from-zetachain --network localhost --contract 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB --amount 1 --target 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe --recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --zrc20 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c --withdraw true
npx hardhat swap-from-zetachain \
--network localhost \
--contract 0xc351628EB244ec633d5f21fBD6621e1a683B1181 \
--amount 1 \
--target 0x65a45c57636f9BcCeD4fe193A602008578BcA90b \
--recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
--zrc20 0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0 \
--withdraw true
```

## Swap on ZetaChain Without Withdrawing
Expand All @@ -329,7 +348,14 @@ To swap a ZRC-20 token for another ZRC-20 on ZetaChain and transfer it to a
recipient on ZetaChain, run:

```
npx hardhat swap-from-zetachain --network localhost --contract 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB --amount 1 --target 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe --recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --zrc20 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c --withdraw false
npx hardhat swap-from-zetachain \
--network localhost \
--contract 0xc351628EB244ec633d5f21fBD6621e1a683B1181 \
--amount 1 \
--target 0x65a45c57636f9BcCeD4fe193A602008578BcA90b \
--recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
--zrc20 0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0 \
--withdraw false
```

## Conclusion
Expand All @@ -345,4 +371,4 @@ on ZetaChain, providing greater flexibility for a variety of use cases.
You can find the source code for this tutorial in the example contracts
repository:

https://github.com/zeta-chain/example-contracts/tree/main/examples/swap]
https://github.com/zeta-chain/example-contracts/tree/main/examples/swap
fadeev marked this conversation as resolved.
Show resolved Hide resolved
25 changes: 18 additions & 7 deletions src/pages/developers/tutorials/swap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ their native chain, whether it's an EVM chain or Bitcoin.

```
npx hardhat compile --force
npx hardhat deploy --gateway 0x6c533f7fe93fae114d0954697069df33c9b74fd7 --network zeta_testnet
npx hardhat deploy --gateway 0x6c533f7fe93fae114d0954697069df33c9b74fd7 --uniswap-router 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe --network zeta_testnet
fadeev marked this conversation as resolved.
Show resolved Hide resolved
fadeev marked this conversation as resolved.
Show resolved Hide resolved
```

```
Expand All @@ -285,7 +285,7 @@ npx hardhat deploy --gateway 0x6c533f7fe93fae114d0954697069df33c9b74fd7 --networ
## Swap from Base Sepolia to Polygon Amoy

```
npx hardhat evm-deposit-and-call
npx hardhat evm-deposit-and-call \
--receiver 0x162CefCe314726698ac1Ee5895a6c392ba8e20d3 \
--amount 0.001 \
--network base_sepolia \
Expand All @@ -306,7 +306,7 @@ npx hardhat localnet
Compile the contract and deploy it to localnet by running:

```
yarn deploy:localnet
npx hardhat deploy --name Swap --network localhost --gateway 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 --uniswap-router 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
```

You should see output similar to:
Expand All @@ -315,15 +315,20 @@ You should see output similar to:
🔑 Using account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

🚀 Successfully deployed contract on localhost.
📜 Contract address: 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB
📜 Contract address: 0xc351628EB244ec633d5f21fBD6621e1a683B1181
```

## Swapping Gas Tokens for ERC-20 Tokens

To swap gas tokens for ERC-20 tokens, run the following command:

```
npx hardhat swap-from-evm --network localhost --receiver 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB --amount 1 --target 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c --recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
npx hardhat swap-from-evm \
--network localhost \
--receiver 0xc351628EB244ec633d5f21fBD6621e1a683B1181 \
--amount 1 \
--target 0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0 \
--recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
```

This script deposits tokens into the gateway on a connected EVM chain and sends
Expand Down Expand Up @@ -353,7 +358,13 @@ To swap ERC-20 tokens for gas tokens, adjust the command by specifying the
ERC-20 token you're swapping from using the `--erc20` parameter:

```
npx hardhat swap-from-evm --network localhost --receiver 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB --amount 1 --target 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe --recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --erc20 0x0B306BF915C4d645ff596e518fAf3F9669b97016
npx hardhat swap-from-evm \
--network localhost \
--receiver 0xc351628EB244ec633d5f21fBD6621e1a683B1181 \
--amount 1 \
--target 0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0 \
--recipient 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 \
--erc20 0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E
```

Here, the `--erc20` option specifies the ERC-20 token address you're swapping
Expand Down Expand Up @@ -386,4 +397,4 @@ token approvals in cross-chain swaps.
You can find the source code for the tutorial in the example contracts
repository:

[https://github.com/zeta-chain/example-contracts/tree/main/examples/swap](https://github.com/zeta-chain/example-contracts/tree/main/examples/swap)
https://github.com/zeta-chain/example-contracts/tree/main/examples/swap
fadeev marked this conversation as resolved.
Show resolved Hide resolved