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

Update tutorials for Gateway on testnet #499

Merged
merged 13 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/components/Docs/components/ContractAddresses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type ContractAddressData = {
type ContractAddressesByChain = Record<string, ContractAddressData[]>;

const addressesUrl: Record<NetworkType, string> = {
testnet: "https://raw.githubusercontent.com/zeta-chain/protocol-contracts/main/v1/data/addresses.testnet.json",
mainnet: "https://raw.githubusercontent.com/zeta-chain/protocol-contracts/main/v1/data/addresses.mainnet.json",
testnet: "https://raw.githubusercontent.com/zeta-chain/protocol-contracts/main/v2/data/addresses.testnet.json",
mainnet: "https://raw.githubusercontent.com/zeta-chain/protocol-contracts/main/v2/data/addresses.mainnet.json",
fadeev marked this conversation as resolved.
Show resolved Hide resolved
};

const groupDataByChain = (data: ContractAddressData[]) =>
Expand Down
10 changes: 5 additions & 5 deletions src/pages/developers/apps/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pragma solidity 0.8.26;
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/UniversalContract.sol";

contract UniversalApp is UniversalContract {
function onCrossChainCall(
zContext calldata context,
function onCall(
MessageContext calldata context,
address zrc20,
uint256 amount,
bytes calldata message
Expand Down Expand Up @@ -67,7 +67,7 @@ universal app:
allowfullscreen
></iframe>

A call to a universal app triggers an `onCrossChainCall` method.
A call to a universal app triggers an `onCall` method.

A universal app receives:

Expand All @@ -81,8 +81,8 @@ corresponding ZRC-20 token on ZetaChain. ZRC-20 tokens are ERC-20-compatible and
can be permissionlessly transferred back (withdrawn) to their original chain
(ZRC-20 ETH on ZetaChain becomes ETH on Ethereum).

`onCrossChainCall` also has access to additional context information such as the
original sender address and chain ID.
`onCall` also has access to additional context information such as the original
sender address and chain ID.

Universal apps can also initiate token transfers and contract calls to connected
chains.
Expand Down
17 changes: 8 additions & 9 deletions src/pages/developers/chains/evm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function.
depositAndCall(address receiver, bytes calldata payload, RevertOptions calldata revertOptions) external payable;
```

After the cross-chain transaction is processed, the `onCrossChainCall` function
of a universal app contract is executed.
After the cross-chain transaction is processed, the `onCall` function of a
universal app contract is executed.

The `receiver` must be a universal app contract address.

Expand All @@ -67,8 +67,8 @@ pragma solidity 0.8.7;
import "@zetachain/protocol-contracts/contracts/zevm/interfaces/zContract.sol";

contract UniversalApp is UniversalContract {
function onCrossChainCall(
zContext calldata context,
function onCall(
MessageContext calldata context,
address zrc20,
uint256 amount,
bytes calldata message
Expand All @@ -78,7 +78,7 @@ contract UniversalApp is UniversalContract {
}
```

`onCrossChainCall` receives:
`onCall` receives:

- `message`: value of the `payload`
- `amount`: amount of deposited tokens
Expand All @@ -90,10 +90,9 @@ contract UniversalApp is UniversalContract {
- `context.chainID`: chain ID of the connected chain from which the call was
made

When calling a universal app, the payload contains bytes passed to
`onCrossChainCall` as `message`. You don't need to pass a function selector in
the payload as the only function that can be called from a connected chain is
`onCrossChainCall`.
When calling a universal app, the payload contains bytes passed to `onCall` as
`message`. You don't need to pass a function selector in the payload as the only
function that can be called from a connected chain is `onCall`.

## Deposit ERC-20 Tokens and Call a Universal App

Expand Down
21 changes: 10 additions & 11 deletions src/pages/developers/tokens/zrc20.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ flowchart LR
SystemContract("System Contract")
subgraph contract ["Omnichain contract"]
addr("Contract address")
subgraph onCrossChainCall
subgraph onCall
msg("bytes calldata message")
zrc20("address zrc20")
amount("uint256 amount")
context("zContext calldata context")
context("MessageContext calldata context")
end
end
end
Expand All @@ -116,8 +116,8 @@ If the input data field is not empty, the protocol looks up the first 20 bytes
of the input data field. If the first 20 bytes correspond to an EOA address on
ZetaChain, the token will be deposited to that address. If the first 20 bytes
correspond to a contract address on ZetaChain, the token will be deposited to
that contract and the `onCrossChainCall` function of that contract will be
called with the remaining input data as the `message`.
that contract and the `onCall` function of that contract will be called with the
remaining input data as the `message`.

When depositing native gas tokens from EVM-based connected chains, there is no
additional cross-chain fee. If you send 1 token to a TSS address, you will
Expand Down Expand Up @@ -146,11 +146,11 @@ flowchart LR
SystemContract("System Contract")
subgraph contract ["Omnichain contract"]
addr("Contract address")
subgraph onCrossChainCall
subgraph onCall
msg("bytes calldata message")
zrc20("address zrc20")
amount("uint256 amount")
context("zContext calldata context")
context("MessageContext calldata context")
end
end
end
Expand All @@ -173,13 +173,12 @@ The `deposit` method accepts the following parameters:
- `recipient`: the address on ZetaChain to deposit the tokens to. If the
recipient is an EOA, the tokens will be deposited to the recipient's address.
If the recipient is a contract, the tokens will be deposited to the contract
and the `onCrossChainCall` function of that contract will be called with the
`message` as an argument.
and the `onCall` function of that contract will be called with the `message`
as an argument.
- `asset`: the address of the ERC-20 token to deposit.
- `amount`: the amount of tokens to deposit.
- `message`: an arbitrary message to be passed to the `onCrossChainCall`
function of the recipient contract. If the recipient is an EOA, the message
should be empty.
- `message`: an arbitrary message to be passed to the `onCall` function of the
recipient contract. If the recipient is an EOA, the message should be empty.

## Withdrawing ZRC-20 Tokens from ZetaChain

Expand Down
22 changes: 11 additions & 11 deletions src/pages/developers/tutorials/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
"description": "Learn how to set up a smart contract template, create an account, and use faucet"
},
"hello": {
"title": "First Universal App on Localnet",
"title": "Message Passing",
"readTime": "30 min",
"description": "Learn how to create, deploy and interact with a universal app"
},
"swap-tss": {
"title": "Swap on Testnet",
"readTime": "30 min",
"description": "Implement an omnichain swap app compatible with chains like Ethereum, BNB and Bitcoin"
"description": "Learn the fundamentals of message passing and cross-chain contract calls"
},
"swap": {
"title": "Swap on Localnet",
"title": "Swap",
"readTime": "30 min",
"description": "Implement an omnichain swap app compatible with chains like Ethereum, BNB and Bitcoin"
"description": "Implement a universal swap app compatible with chains like Ethereum, Solana and Bitcoin"
},
"swap-any": {
"title": "Swap Any Token on Localnet",
"title": "Swap Any Token",
"readTime": "60 min",
"description": "Enhance the universal swap app with the ability to swap to any token"
},
"nft": {
"title": "NFT",
"readTime": "60 min",
"description": "Enhance the omnichain swap app with the ability to swap to any token"
"description": "Mint a universal NFT, which can be transferred between connected chains"
},
"localnet": {
"title": "Localnet",
Expand Down
Loading
Loading