evm: line edits
This commit is contained in:
parent
e28ee15ac0
commit
f8cc94e6c8
|
@ -2,42 +2,55 @@
|
|||
|
||||
This section will explain how to properly interact with the NFT Layer in an EVM ecosystem.
|
||||
|
||||
## Configuring the interface
|
||||
|
||||
[Here]() is the interface for applications to interact with Wormhole's NFT layer.
|
||||
//TODO link to file in github so doesn't become stale
|
||||
|
||||
Instantiating the interface will depend on your development ecosystem and blockchain. The Wormhole xAsset contract address is usually stored in your contract address.
|
||||
|
||||
Below is an example line of code to instantiate the interface for mainnet Ethereum:
|
||||
|
||||
```
|
||||
address private wormhole_NFT_bridge_address = address(0x6FFd7EdE62328b3Af38FCD61461Bbfc52F5651fE);
|
||||
INFTBridge NFT_bridge = INFTBridge(wormhole_nft_bridge_address);
|
||||
```
|
||||
// contracts/NFTBridge.sol
|
||||
// SPDX-License-Identifier: Apache 2
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
## Transferring a NFT
|
||||
|
||||
import "./NFTBridgeGetters.sol";
|
||||
import "./NFTBridgeStructs.sol";
|
||||
The Wormhole NFT Bridge only supports tokens that support the ERC-721 interface and will create a wrapped NFT with identical metadata. How this is implemented varies by ecosystem.
|
||||
|
||||
interface INFTBridge is NFTGetters {
|
||||
**Note**: Unlike xAssets, there is no attestation required for bridging NFTs.
|
||||
|
||||
function transferNFT(address token, uint256 tokenID, uint16 recipientChain, bytes32 recipient, uint32 nonce) external payable returns (uint64 sequence);
|
||||
To transfer a NFT, there are three steps:
|
||||
|
||||
function completeTransfer(bytes memory encodeVm) external ;
|
||||
1. Initiate the NFT transfer
|
||||
- This function call will return a `sequence` (uint64) that is used in the VAA retrieval step
|
||||
|
||||
function encodeTransfer(NFTBridgeStructs.Transfer memory transfer) external pure returns (bytes memory encoded);
|
||||
|
||||
function parseTransfer(bytes memory encoded) external pure returns (NFTBridgeStructs.Transfer memory transfer);
|
||||
|
||||
function onERC721Received(address operator, address, uint256, bytes calldata) external view returns (bytes4);
|
||||
```
|
||||
transferNFT(tokenAddress, tokenID, recipientChain, recipient, nonce);
|
||||
```
|
||||
|
||||
2. Retrieve the emitted VAA.
|
||||
- _Note: NFT Transfer VAAs are retrieved from the Guardian Network by the `emitterChainID`, `emitterAddress`, and `sequence`_
|
||||
```
|
||||
const emitterAddr = getEmitterAddressEth(network.NFTBridgeAddress);
|
||||
const seq = parseSequenceFromLogEth(tx, network.bridgeAddress);
|
||||
const vaaURL = `${config.wormhole.restAddress}/v1/signed_vaa/${network.wormholeChainId}/${emitterAddr}/${seq}`;
|
||||
let vaaBytes = await (await fetch(vaaURL)).json();
|
||||
while (!vaaBytes.vaaBytes) {
|
||||
console.log("VAA not found, retrying in 5s!");
|
||||
await new Promise((r) => setTimeout(r, 5000)); //Timeout to let Guardiand pick up log and have VAA ready
|
||||
vaaBytes = await (await fetch(vaaURL)).json();
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Overview
|
||||
3. Complete the NFT transfer
|
||||
|
||||
Only ERC-721 supported, creates a wrapped NFT with identical metadata. Implementation varies by ecosystem
|
||||
```
|
||||
completeTransfer(VAA);
|
||||
```
|
||||
|
||||
## Sending an NFT
|
||||
|
||||
- Unlike xAssets, there is no registration process
|
||||
- Code example to send
|
||||
|
||||
## Receiving an NFT
|
||||
|
||||
- completeTransfer code examples
|
||||
## Additional utility
|
||||
|
||||
//TODO NFT verification and perhaps some other common usecases
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
This section will explain how to properly interact with the Wormhome Core Layer in an EVM ecosystem.
|
||||
|
||||
# Configuring the interface
|
||||
## Configuring the interface
|
||||
|
||||
[Here]() is the interface for applications to interact with Wormhole's xAsset layer.
|
||||
//TODO link to file in github so doesn't become stale
|
||||
|
|
Loading…
Reference in New Issue