Skip to content

Commit 00f83aa

Browse files
committed
docs: current wire formats
1 parent eeea26f commit 00f83aa

File tree

4 files changed

+89
-8
lines changed

4 files changed

+89
-8
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ target/
88
/broadcast/*/31337/
99
/broadcast/**/dry-run/
1010

11-
# Docs
12-
docs/
13-
1411
# Dotenv file
1512
.env
1613

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@ Wormhole’s Native Token Transfers (NTT) is an open, flexible, and composable f
1212

1313
There are two basic components to NTT:
1414

15-
(1) **Transceiver**: This contract is responsible for sending NTT transfers forwarded through the `NttManager` on the source chain and delivered to a corresponding peer `NttManager` on the recipient chain. Transceivers should follow the `ITransceiver` interface. Transceivers can be defined independently of Wormhole core and can be modified to support any verification backend.
16-
17-
(2) **NttManager**: The NttManager contract is responsible for managing the token and the Transceivers. It also handles the rate-limiting and the message attestation logic. Note that each `NttManager` corresponds to a single token. However, a single `NttManager` can can control multiple transceivers.
15+
(1) **Transceiver**: This contract is responsible for sending NTT transfers forwarded through the `NttManager` on the source chain and delivered to a corresponding peer `NttManager` on the recipient chain. Transceivers should follow the `ITransceiver` interface. Transceivers can be defined independently of Wormhole core and can be modified to support any verification backend. See [docs/Transceiver.md](./docs/Transceiver.md) for more info.
1816

17+
(2) **NttManager**: The NttManager contract is responsible for managing the token and the Transceivers. It also handles the rate-limiting and the message attestation logic. Note that each `NttManager` corresponds to a single token. However, a single `NttManager` can control multiple transceivers. See [docs/NttManager.md](./docs/NttManager.md) for more info.
1918

2019
<figure>
2120
<img src="images/ntt_architecture__with_custom_attestation.jpg" alt="NTT Architecture Diagram">
2221
<figcaption>Figure: NTT Architecture Diagram with Custom Attestations.</figcaption>
2322
</figure>
2423

25-
2624
## Amount trimming
2725

2826
In the payload, amounts are encoded as unsigned 64 bit integers, and capped at the configured `TRIMMED_DECIMALS` (e.g. 8) decimal value.
@@ -52,5 +50,6 @@ The action identifier specifies the runtime. Currently, these are as follows:
5250
- 1: evm
5351
- 2: solana
5452

55-
___
53+
---
54+
5655
⚠️ **WARNING:** Ensure that if the `NttManager` on the source chain is configured to be in `LOCKING` mode, the corresponding `NttManager`s on the target chains are configured to be in `BURNING` mode. If not, transfers will NOT go through and user funds may be lost! Proceed with caution!

docs/NttManager.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# NTT Manager
2+
3+
## Overview
4+
5+
The NttManager contract is responsible for managing the token and the Transceivers. It also handles the rate-limiting and the message attestation logic. Note that each `NttManager` corresponds to a single token. However, a single `NttManager` can control multiple transceivers.
6+
7+
## Message Specification
8+
9+
NttManagers do not directly publish messages. These will be wrapped in a [TransceiverMessage](./Transceiver.md#transceivermessage).
10+
11+
```go
12+
[32]byte id // a unique message identifier
13+
[32]byte sender // original message sender address
14+
uint16 payload_len // length of the payload
15+
[]byte payload
16+
```
17+
18+
### Payloads
19+
20+
#### NativeTokenTransfer
21+
22+
```go
23+
[4]byte prefix = 0x994E5454 // 0x99'N''T''T'
24+
uint8 decimals // number of decimals for the amount
25+
uint64 amount // amount being transferred
26+
[32]byte source_token // source chain token address
27+
[32]byte recipient_address // the address of the recipient
28+
uint16 recipient_chain // the Wormhole Chain ID of the recipient
29+
```

docs/Transceiver.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Transceiver
2+
3+
## Overview
4+
5+
The Transceiver is intended to offer a protocol-agnostic interface for sending and receiving cross-chain messages. For Native Token Transfers, this entails initiating attestation generation on the source chain, verifying the resulting attestation on the destination chain, and delivering the message to the associated `NttManager`.
6+
7+
In the provided implementations ([EVM](/evm/src/Transceiver/Transceiver.sol)/[SVM](/solana/programs/example-native-token-transfers/src/transceivers/wormhole/)), Transceiver are intended to have a many-to-one or one-to-one relationship with Managers.
8+
9+
## Message Specification
10+
11+
### TransceiverMessage
12+
13+
NttManager message emitted by a Transceiver implementation. Each message includes a Transceiver-specified 4-byte prefix. This should be a constant value, set by a protocol-specific Transceiver implementation, that identifies the payload as an NTT Transceiver emitted payload.
14+
15+
```go
16+
[4]byte prefix
17+
[32]byte source_ntt_manager_address
18+
[32]byte recipient_ntt_manager_address
19+
uint16 ntt_manager_payload_length
20+
[]byte ntt_manager_payload
21+
uint16 transceiver_payload_length
22+
[]byte transceiver_payload
23+
```
24+
25+
### Wormhole Transceiver
26+
27+
#### TransceiverMessage
28+
29+
```go
30+
prefix = 0x9945FF10 // 0x99'E''W''H'
31+
```
32+
33+
#### Initialize Transceiver
34+
35+
```go
36+
[4]byte prefix = 0x9c23bd3b // bytes4(keccak256("WormholeTransceiverInit"))
37+
[32]byte ntt_manager_address // address of the associated manager
38+
uint8 ntt_manager_mode // the locking/burning mode of the associated manager
39+
[32]byte token_address // address of the associated manager's token
40+
uint8 token_decimals // the number of decimals for that token
41+
```
42+
43+
Mode is an enum.
44+
45+
```
46+
Locking = 0
47+
Burning = 1
48+
```
49+
50+
#### Transceiver (Peer) Registration
51+
52+
```go
53+
[4]byte prefix = 0x18fc67c2 // bytes4(keccak256("WormholePeerRegistration"))
54+
uint16 peer_chain_id // Wormhole Chain ID of the foreign peer transceiver
55+
[32]byte peer_address // the address of the foreign peer transceiver
56+
```

0 commit comments

Comments
 (0)