Skip to content

Commit

Permalink
Merge branch 'main' into ntt_docker_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ilariae authored Dec 23, 2024
2 parents 241614a + b2df662 commit fe52946
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 7 deletions.
1 change: 1 addition & 0 deletions build/contract-integrations/native-token-transfers/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ title: Native Token Transfers
nav:
- index.md
- deployment-process
- 'NTT CLI Commands': 'cli-commands.md'
- configuration
- 'Managers and Transceivers': 'managers-transceivers.md'
- 'FAQS': faqs.md
47 changes: 47 additions & 0 deletions build/contract-integrations/native-token-transfers/cli-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: NTT CLI Commands
description: A comprehensive guide to the Native Token Transfers (NTT) CLI, detailing commands for managing token transfers across chains within the Wormhole ecosystem.
---

# NTT CLI Commands

## Introduction

The NTT Command-Line Interface (CLI) is a powerful tool for managing native token transfers across multiple blockchain networks within the Wormhole ecosystem. This page provides a comprehensive list of available commands, their descriptions, and examples to help you interact with and configure the NTT system effectively. Whether initializing deployments, updating configurations, or working with specific chains, the NTT CLI simplifies these operations through its intuitive commands.

## Table of Commands

The following table lists the available NTT CLI commands, descriptions, and examples.

!!! note
To explore detailed information about any NTT CLI command, including its options and examples, you can append `--help` to the command. This will display a comprehensive guide for the specific command.

### General Commands

| Command | Description | Examples |
|-----------------------------------------|-------------------------------------------------------|--------------------------|
| `ntt update` | update the NTT CLI | `ntt update` |
| `ntt new <path>` | create a new NTT project | `ntt new my-ntt-project` |
| `ntt add-chain <chain>` | add a chain to the deployment file | `ntt add-chain Ethereum --token 0x1234... --mode burning --latest`|
| `ntt upgrade <chain>` | upgrade the contract on a specific chain | `ntt upgrade Solana --ver 1.1.0`|
| `ntt clone <network> <chain> <address>` | initialize a deployment file from an existing contract| `ntt clone Mainnet Solana Sol5678...`|
| `ntt init <network>` | initialize a deployment file | `ntt init devnet` |
| `ntt pull` | pull the remote configuration | `ntt pull` |
| `ntt push` | push the local configuration | `ntt push` |
| `ntt status` | check the status of the deployment | `ntt status` |

### Configuration Commands

| Command | Description | Examples |
|---------------------------------------------|----------------------------------------|-------------------------------------|
| `ntt config set-chain <chain> <key> <value>`| set a configuration value for a chain | `ntt config set-chain Ethereum scan_api_key`|
| `ntt config unset-chain <chain> <key>` | unset a configuration value for a chain| `ntt config unset-chain Ethereum scan_api_key`|
| `ntt config get-chain <chain> <key>` | get a configuration value for a chain | `ntt config get-chain Ethereum scan_api_key`|

### Solana Commands

| Command | Description | Examples |
|-----------------------------------------------|---------------------------------------------------------|------------------|
| `ntt solana key-base58 <keypair>` | print private key in base58 | `ntt solana key-base58 /path/to/keypair.json`|
| `ntt solana token-authority <programId>` | print the token authority address for a given program ID| `ntt solana token-authority Sol1234...`|
| `ntt solana ata <mint> <owner> <tokenProgram>`| print the token authority address for a given program ID| `ntt solana ata Mint123... Owner123... token22`|
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ description: Deploy and configure Wormhole’s Native Token Transfers (NTT) for

If you still need to do so, deploy the token contract to the destination or spoke chains.

### Requirements for Token Deployment

Wormhole’s NTT is an open framework that supports various deployment modes. The NTT CLI currently supports two deployment modes: burn-and-mint and hub-and-spoke. These modes differ in how tokens are managed across chains.

#### Burn-and-Mint Mode

Tokens integrated with `NttManager` in `burning` mode require the following two functions to be present:

- `burn(uint256 amount)`
Expand All @@ -23,6 +29,27 @@ These functions aren't part of the standard ERC-20 interface. The [`INttToken` i

Later, you set mint authority to the corresponding `NttManager` contract. You can also follow the scripts in the [example NTT token](https://github.com/wormhole-foundation/example-ntt-token){target=\_blank} repository to deploy a token contract.

#### Hub-and-Spoke Mode

A central hub chain (e.g., Ethereum) manages the total token supply in hub-and-spoke mode. Other chains (spokes) mint or burn tokens during cross-chain transfers, ensuring consistency with the locked tokens on the hub chain.

- **Hub chain** - tokens are locked on the hub chain when transferring to spoke chains
- **Spoke chains** - tokens are native to the spoke chains and are either minted or burned during cross-chain transfers

!!! note
The only requirement for using the NTT framework is an ERC20 token, which can be newly deployed or existing. Steps like setting mint authority apply only to spoke chains.

For example, when transferring tokens from Ethereum (hub) to Polygon (spoke), the NTT Manager locks tokens on Ethereum, and the corresponding amount is minted on Polygon. Similarly, transferring tokens back from Polygon to Ethereum burns the tokens on Polygon and unlocks the equivalent tokens on Ethereum.

This process ensures that the total token supply remains consistent across all chains, with the hub chain acting as the source of truth.

For more detailed information, see the [Deployment Models](/docs/learn/messaging/native-token-transfers/deployment/){target=\_blank} page.

### Key Differences Between Modes

- **Burn-and-mint** - tokens must implement custom `mint` and `burn` functions, allowing each chain to manage token issuance independently
- **Hub-and-spoke** - tokens only need to be ERC20 compliant, with the hub chain acting as the source of truth for supply consistency

## Deploy NTT

Create a new NTT project:
Expand All @@ -32,7 +59,7 @@ ntt new my-ntt-deployment
cd my-ntt-deployment
```

Initialize a new `deployment.json` file, specifying the network:
Initialize a new `deployment.json` file specifying the network:

=== "Testnet"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ntt new my-ntt-deployment
cd my-ntt-deployment
```

Initialize a new `deployment.json` file, specifying the network:
Initialize a new `deployment.json` file specifying the network:

=== "Testnet"

Expand All @@ -48,7 +48,7 @@ Initialize a new `deployment.json` file, specifying the network:
solana-keygen grind --starts-with w:1 --ignore-case
```

2. Set Solana configuration to use the new key pair create in step 1:
2. Set Solana configuration to use the new key pair created in step 1:
```bash
solana config set --keypair INSERT_PATH_TO_KEYPAIR_JSON
```
Expand Down Expand Up @@ -83,11 +83,21 @@ Initialize a new `deployment.json` file, specifying the network:
spl-token mint INSERT_TOKEN_ADDRESS 1000
```



!!! note
NTT versions `>=v2.0.0+solana` support SPL tokens with transfer hooks.

### Hub Chain Requirements

For hub chain deployments on Solana, the token can be either an SPL or Token2022. Hub chain tokens do not require additional configuration, such as setting the mint authority.

For more detailed information, see the [Deployment Models](/docs/learn/messaging/native-token-transfers/deployment/){target=\_blank} page.

### Burning Mode Requirements

In burning mode, tokens require their mint authority to be assigned to the NTT program. This allows the NTT Manager to mint and burn tokens as needed during cross-chain transfers.

All necessary steps for configuring burning mode, including mint authority setup, are explained in the sections below.

## Configuration and Deployment

### Generate NTT Program Key Pair
Expand Down Expand Up @@ -140,7 +150,7 @@ The NTT Solana program will then compile and deploy, returning the program ID.
The NTT CLI takes inspiration from [git](https://git-scm.com/){target=\_blank}. You can run:

- `ntt status` - checks whether your `deployment.json` file is consistent with what is on-chain
- `ntt pull` - syncs your `deployment.json` file with the on-chain configuration and set up rate limits with the appropriate number of decimals, depending on the specific chain. For example:
- `ntt pull` - syncs your `deployment.json` file with the on-chain configuration and sets up rate limits with the appropriate number of decimals, depending on the specific chain. For example:

For Solana, the limits are set with 9 decimal places:
```json
Expand All @@ -156,7 +166,7 @@ The NTT CLI takes inspiration from [git](https://git-scm.com/){target=\_blank}.
}
```

This initial configuration ensures that the rate limits are correctly represented for each chain's token precision
This initial configuration ensures that the rate limits are correctly represented for each chain's token precision.

### Deploy NTT to Solana

Expand Down

0 comments on commit fe52946

Please sign in to comment.