From 0479f697c16d55ca99a912f8a57552d10fccbe4c Mon Sep 17 00:00:00 2001 From: _dssei_ Date: Fri, 13 Sep 2024 10:10:57 -0700 Subject: [PATCH] Allowlist tutorial --- pages/dev-tutorials/_meta.json | 1 + .../dev-tutorials/tokenfactory-allow-list.mdx | 84 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 pages/dev-tutorials/tokenfactory-allow-list.mdx diff --git a/pages/dev-tutorials/_meta.json b/pages/dev-tutorials/_meta.json index be67f51e..04cabf51 100644 --- a/pages/dev-tutorials/_meta.json +++ b/pages/dev-tutorials/_meta.json @@ -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", diff --git a/pages/dev-tutorials/tokenfactory-allow-list.mdx b/pages/dev-tutorials/tokenfactory-allow-list.mdx new file mode 100644 index 00000000..7ce9d29d --- /dev/null +++ b/pages/dev-tutorials/tokenfactory-allow-list.mdx @@ -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 + +You can obtain devnet tokens from one of the faucets listed [here](../dev-ecosystem-providers/faucets). + +## 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. + +For detailed descriptions of these arguments, use `seid help` in the CLI. + +## 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).