Skip to content

Commit

Permalink
Allowlist tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
dssei committed Sep 13, 2024
1 parent 7ce0644 commit 0479f69
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions pages/dev-tutorials/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"evm-general": "EVM (General)",
"evm-cli-tutorial": "EVM (CLI)",
"tokenfactory-tutorial": "Token Factory",
"tokenfactory-allow-list": "Token Allow List Add-on",
"nft-contract-tutorial": "NFT Contracts",
"pointer-contracts": "Pointer Contracts",
"multi-sig-accounts": "Multi-Sig Accounts",
Expand Down
84 changes: 84 additions & 0 deletions pages/dev-tutorials/tokenfactory-allow-list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { Callout } from 'nextra/components';

# Introducing Token Add-ons

As you have learned form the [Token Factory tutorial](tokenfactory-tutorial.mdx), the `tokenfactory` module enables any account to create new tokens with a unique identifier based on the creator's address.

Introducing Token Add-ons, a set of features that can be added to your token to enhance its functionality.
With the first add-on being an allow list, which restricts the transferability of the token to a specific set of addresses.

In this tutorial, we will learn how to create a token with an allow list.

## Requirements

To create a token on the devnet, ensure you have the following setup:

- The `seid` CLI
- A wallet with SEI tokens on devnet

<Callout type='info'>You can obtain devnet tokens from one of the faucets listed [here](../dev-ecosystem-providers/faucets).</Callout>

## Creating a Denom with Allow List

First, we need to prepare a list of addresses that are allowed to transfer the token and save it to a JSON file.
The format of the allow list is as follows:

```json
{
"addresses": [
"address1",
"address2",
"address3"
]
}
```

Where each address is a valid Sei bech32 address or EVM 0x prefixed address. Please note, that 0x addresses will be converted to bech32 addresses when the allow list is persisted.

```bash copy
seid tx tokenfactory create-denom $DENOM --from=$ACCOUNT --allow-list=$ALLOW_LIST_FILE_PATH --chain-id=arctic-1 --node=https://rpc.arctic-1.seinetwork.io/ --broadcast-mode=block --fees=20000usei
```

This command creates a new coin with specific allow list.

### Understanding Command Line Arguments

When executing commands in this tutorial, you'll encounter several arguments. Here's a brief overview of what each means:

- `--allow-list $ALLOW_LIST_FILE_PATH`: This specifies the path to the allow list file that we have created in the previous step. E.g. `allowlist.json`.
- `--chain-id arctic-1`: This specifies the network where the command will be executed. In this case, `arctic-1` is the identifier for the Sei devnet.
- `--node https://rpc.arctic-1.seinetwork.io/ `: This points to the RPC URL of the node you are interacting with.
- `--broadcast-mode block`: This determines how your transaction is broadcasted to the network. The `block` mode means the transaction will wait to be included in a block before returning a response. This is a safer option as it confirms your transaction is processed.
- `--fees 20000usei`: This is used to specify the transaction fee.

Understanding these arguments will help you execute the commands more confidently and customize them as needed for different scenarios.

<Callout type='info'>For detailed descriptions of these arguments, use `seid help` in the CLI.</Callout>

## Updating Token Allow List

To update the allow list of a token, you can use the following command:

```bash copy
seid tx tokenfactory update-denom $DENOM --from=$ACCOUNT --allow-list=$ALLOW_LIST_FILE_PATH --chain-id=arctic-1 --node=https://rpc.arctic-1.seinetwork.io/ --broadcast-mode=block --fees=20000usei
```

This command updates the allow list of a token.

To allow all addresses agian to transfer the token, you can simply submit an empty allow list.

## Querying Token Allow List

You may query the allow list of a token using the node REST endpoint. E.g.:
```bash copy
curl -X 'GET' \
'https://rest-arctic-1.sei-apis.com/sei-protocol/seichain/tokenfactory/denoms/allow_list?denom=factory/{ACCOUNT}/{DENOM}' \
-H 'accept: application/json'
```


## EVM Support

To enable seamless use of this token in EVM environments, we can create a pointer contract. The process is described in [Token Factory tutorial](tokenfactory-tutorial.mdx#create-pointer-contract).

For more advanced features and detailed insights, please refer to the [Token Factory module documentation](https://github.com/sei-protocol/sei-chain/tree/main/x/tokenfactory).

0 comments on commit 0479f69

Please sign in to comment.