From 5584262fa8b5fd160672e58d68076686a59f1828 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Mon, 21 Oct 2024 10:26:40 +0530 Subject: [PATCH] Move instructions to deploy and transfer new tokens to a separate file --- README.md | 1 + ops/deployments-from-scratch.md | 24 +------------ ops/nitro-token-ops.md | 63 +++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 23 deletions(-) create mode 100644 ops/nitro-token-ops.md diff --git a/README.md b/README.md index ac60865..ea70127 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Stacks to run a node for laconic testnet - [Update deployments after code changes](./ops/update-deployments.md) - [Halt stage0 and start stage1](./ops/stage0-to-stage1.md) - [Create deployments from scratch (for reference only)](./ops/deployments-from-scratch.md) +- [Deploy and transfer new tokens for nitro operations](./ops/nitro-token-ops.md) ## Join LORO testnet diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index bff8bb5..fdff7e9 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -253,29 +253,7 @@ laconic-so deployment --dir nitro-contracts-deployment logs nitro-contracts -f ``` -* To deploy another token: - - ```bash - export TOKEN_NAME="TestToken2" - export TOKEN_SYMBOL="TST2" - - # Note: Token supply denotes actual number of tokens and not the supply in Wei - export INITIAL_TOKEN_SUPPLY="10000000" - - laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && TOKEN_NAME=$TOKEN_NAME TOKEN_SYMBOL=$TOKEN_SYMBOL INITIAL_TOKEN_SUPPLY=$INITIAL_TOKEN_SUPPLY yarn contracts:deploy-token-geth" - ``` - -* To transfer a token to an account: - - ```bash - export GETH_CHAIN_ID=1212 - export TOKEN_NAME="" - export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.$TOKEN_NAME.address' /app/deployment/nitro-addresses.json") - export ACCOUNT="" - export AMOUNT="" - - laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $ASSET_ADDRESS --to $ACCOUNT --amount 1000 --network geth" - ``` +* To deploy a new token and transfer it to another account, refer to this [doc](./nitro-token-ops.md) diff --git a/ops/nitro-token-ops.md b/ops/nitro-token-ops.md new file mode 100644 index 0000000..7b8fe66 --- /dev/null +++ b/ops/nitro-token-ops.md @@ -0,0 +1,63 @@ +# Nitro Token Ops + +## Setup + +* Go to the directory where `nitro-contracts-deployment` is present: + + ```bash + cd /srv/bridge + ``` + +## Deploy new token + +* To deploy another token: + + ```bash + # These values can be changed to deploy another token with different name and symbol + export TOKEN_NAME="TestToken2" + export TOKEN_SYMBOL="TST2" + + # Note: Token supply denotes actual number of tokens and not the supply in Wei + export INITIAL_TOKEN_SUPPLY="10000000" + + laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "TOKEN_NAME=$TOKEN_NAME TOKEN_SYMBOL=$TOKEN_SYMBOL INITIAL_TOKEN_SUPPLY=$INITIAL_TOKEN_SUPPLY /app/deploy-l1-tokens.sh" + ``` + +* Recreate `assets.json` to include newly deployed token address: + + ```bash + export GETH_CHAIN_ID="1212" + + laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq --arg chainId \"$GETH_CHAIN_ID\" '{ + (\$chainId): [ + { + \"name\": .[\$chainId][0].name, + \"chainId\": .[\$chainId][0].chainId, + \"contracts\": ( + .[\$chainId][0].contracts + | to_entries + | map(select(.key | in({\"ConsensusApp\":1, \"NitroAdjudicator\":1, \"VirtualPaymentApp\":1}) | not)) + | from_entries + ) + } + ] + }' /app/deployment/nitro-addresses.json" > assets.json + ``` + + * The required config file should be generated at `/srv/bridge/assets.json` + + * Check in the generated file at location `ops/stage2/assets.json` within this repository + +## Transfer deployed tokens to given address + +* To transfer a token to an account: + + ```bash + export GETH_CHAIN_ID=1212 + export TOKEN_NAME="" + export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.$TOKEN_NAME.address' /app/deployment/nitro-addresses.json") + export ACCOUNT="" + export AMOUNT="" + + laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $ASSET_ADDRESS --to $ACCOUNT --amount 1000 --network geth" + ```