Skip to content

Commit

Permalink
Merge branch 'main' into martinh/ntt-cli-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ilariae authored Dec 23, 2024
2 parents 6649c9c + 7313969 commit e9bad7f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
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 e9bad7f

Please sign in to comment.