Adding info to the EVM pages

This commit is contained in:
chase-45 2022-09-14 13:03:57 -04:00
parent 966123223e
commit 0edfae54a6
3 changed files with 86 additions and 6 deletions

View File

@ -1,7 +1,16 @@
# Core Layer
This section will explain how to properly interact with the Wormhome Core Layer in an EVM ecosystem.
# Configuring the Interface
- Get the interface from the repo
- Instantiate it with the core layer contract address for your blockchain. This is dependent on your development ecosystem and blockchain. This value is usually stored in your contract state.
This is the interface for applications to interact with Wormhole's Core Contract to publish messages or verify and parse a received message.
//TODO just link to the github repo, in order to avoid stale information
```
// contracts/Messages.sol
// SPDX-License-Identifier: Apache 2
@ -45,4 +54,23 @@ interface IWormhole is Structs {
function messageFee() external view returns (uint256) ;
}
```
```
//TODO example line of code for instantiating the interface for mainnet Ethereum
## Primary functions
The Wormhole Core Layer effectively only has two important interactions. The ability to emit messages, and the ability to verify messages which originated from other chains.
### Emitting a Message
- Always uses publish message
- explain every argument
- be sure to mention batch VAAs
### Verifying a Message
- Explain how a message should be taken in as a byte array
- Be cognizant of Batch VAAs vs Single VAAs
- entrypoint code vs module code. If using single VAAs, these are the same, but batch VAAs are more complicated to verify
- remember to collect your gas after all the VAAs have been verified

View File

@ -1,6 +1,6 @@
# NFT Layer
This is the interface for applications to interact with Wormhole's NFT Bridge Contract to publish messages or verify and parse a received message.
This section will explain how to properly interact with the NFT Layer in an EVM ecosystem.
```
// contracts/NFTBridge.sol
@ -9,6 +9,7 @@ This is the interface for applications to interact with Wormhole's NFT Bridge Co
pragma solidity ^0.8.0;
import "./NFTBridgeGetters.sol";
import "./NFTBridgeStructs.sol";
interface INFTBridge is NFTGetters {
@ -24,4 +25,19 @@ interface INFTBridge is NFTGetters {
}
```
```
## Overview
Only ERC-721 supported, creates a wrapped NFT with identical metadata. Implementation varies by ecosystem
## Sending an NFT
- Unlike xAssets, there is no registration process
- Code example to send
## Receiving an NFT
- completeTransfer code examples
//TODO NFT verification and perhaps some other common usecases

View File

@ -1,6 +1,10 @@
# xAsset Layer
This is the interface for applications to interact with Wormhole's Token Bridge Contract to publish messages or verify and parse a received message.
This is the interface for applications to interact with the xAsset layer in Wormhole
# Instantiating the interface
- Same as instantiating any other EVM interface / Core Layer / NFT Layer,
```
// contracts/Bridge.sol
@ -10,6 +14,7 @@ pragma solidity ^0.8.0;
import "./BridgeGetters.sol";
//TODO link to file in github so doesn't become stale
interface ITokenBridge is BridgeGetters {
/*
* @dev Produce a AssetMeta message for a given token
@ -76,7 +81,7 @@ interface ITokenBridge is BridgeGetters {
bytes32 recipient,
uint32 nonce,
bytes memory payload
) external payable returns (uint64 sequence);
) external payable returns (uint64 sequence);
function updateWrapped(bytes memory encodedVm) external returns (address token);
@ -124,4 +129,35 @@ interface ITokenBridge is BridgeGetters {
*/
function completeTransferAndUnwrapETH(bytes memory encodedVm) external ;
}
```
```
## Registering New Tokens
- Only needs to be done once globally ever
- Reattesting will update metadata, can be done over and over
- Generally not done by the xDapp contract, but instead by an off-chain process or by hand
- Probably don't need code examples, as it's not advised to do this on chain for most usecases
## Basic Transfer
- Code example for transferring an ERC-20, explain all the args, WORMHOLE ADDRESSES
- Transferring native currency is a special case. Use transferETH for the native currency regardless of which EVM you are on.
- Use this only if you are transferring to an end user wallet. If you're transferring to a smart contract (which you control), use transferWithPayload instead. Explain why
- Mention public relayers, unwrapping conventions, fee schedule.
## Contract Controlled Transfer
- Differences when compared to a basic transfer: has a payload, can only be redeemed if msg.sender == the recipient, doesn't have a relayer fee field because of the redemption restriction.
- Always use this when the destination is a contract
## Redemption
### Basic Token Redemption
- completeTransfer for everything
- completeTransfer and unwrap Eth only for the case where unwrapping ETH is desired
### Contract Controlled Transfer redemption
- completeTransferWithPayload for everything,
- completeTransferAndUnwrapETH as a QoL function. Unwraps the ETH before giving it to the contract.