Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ out/

# Dotenv file
.env

.DS_Store
Binary file removed lib/.DS_Store
Binary file not shown.
15 changes: 15 additions & 0 deletions workshops/erc20-mts/.local.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
################################################################################
# Localhost setup
################################################################################

# Network
ETH_URL=http://localhost:8545
INJ_URL=http://localhost:26657
GRPC_URL=localhost:9900
CHAIN_ID=injective-1


# User
USER=user1
USER_MNEMONIC="copper push brief egg scan entry inform record adjust fossil boss egg comic alien upon aspect dry avoid interest fury window hint race symptom"
USER_PWD=12345678
Comment on lines +13 to +15
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Sensitive information committed

This file includes a full wallet mnemonic and password in version control. Remove .local.env from the repo, add it to .gitignore, and provide a template such as .local.env.example instead.

🤖 Prompt for AI Agents
In workshops/erc20-mts/.local.env around lines 13 to 15, sensitive information
like the wallet mnemonic and password is committed to version control. Remove
the .local.env file from the repository, add .local.env to the .gitignore file
to prevent future commits, and create a .local.env.example template file with
placeholder values for users to fill in their own credentials.

25 changes: 25 additions & 0 deletions workshops/erc20-mts/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
all:

add-keys:
./scripts/import-cli-key.sh
./scripts/import-cast-key.sh

deploy-erc20:
./scripts/deploy-erc20.sh

deploy-erc20-mintburn:
./scripts/deploy-erc20-mintburn.sh

mint-erc20:
./scripts/mint-erc20.sh

balance1-cast:
./scripts/erc20-balance-user1.sh

balance1-cli:
./scripts/cli-balances-user1.sh

deploy-wasm:
./scripts/deploy-wasm.sh

.PHONY: all add-keys deploy-erc20 balance1-cast balance1-cli deploy-wasm
Comment on lines +1 to +25
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ensure all targets are declared phony.
The .PHONY declaration omits deploy-erc20-mintburn and mint-erc20, which can lead to conflicts if files with those names exist.

Apply this diff:

-.PHONY: all add-keys deploy-erc20 balance1-cast balance1-cli deploy-wasm
+.PHONY: all add-keys deploy-erc20 deploy-erc20-mintburn mint-erc20 balance1-cast balance1-cli deploy-wasm
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
all:
add-keys:
./scripts/import-cli-key.sh
./scripts/import-cast-key.sh
deploy-erc20:
./scripts/deploy-erc20.sh
deploy-erc20-mintburn:
./scripts/deploy-erc20-mintburn.sh
mint-erc20:
./scripts/mint-erc20.sh
balance1-cast:
./scripts/erc20-balance-user1.sh
balance1-cli:
./scripts/cli-balances-user1.sh
deploy-wasm:
./scripts/deploy-wasm.sh
.PHONY: all add-keys deploy-erc20 balance1-cast balance1-cli deploy-wasm
all:
add-keys:
./scripts/import-cli-key.sh
./scripts/import-cast-key.sh
deploy-erc20:
./scripts/deploy-erc20.sh
deploy-erc20-mintburn:
./scripts/deploy-erc20-mintburn.sh
mint-erc20:
./scripts/mint-erc20.sh
balance1-cast:
./scripts/erc20-balance-user1.sh
balance1-cli:
./scripts/cli-balances-user1.sh
deploy-wasm:
./scripts/deploy-wasm.sh
.PHONY: all add-keys deploy-erc20 deploy-erc20-mintburn mint-erc20 balance1-cast balance1-cli deploy-wasm
🧰 Tools
🪛 checkmake (0.2.2)

[warning] 25-25: Missing required phony target "clean"

(minphony)


[warning] 25-25: Missing required phony target "test"

(minphony)

🤖 Prompt for AI Agents
In workshops/erc20-mts/Makefile lines 1 to 25, the .PHONY declaration is missing
the targets deploy-erc20-mintburn and mint-erc20. Add these two targets to the
.PHONY line to ensure all make targets are declared phony and prevent conflicts
with files of the same names.

21 changes: 21 additions & 0 deletions workshops/erc20-mts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## ERC20 MTS Workshop

This workshop shows MTS (Multi-VM Token Standard) and how to use it to create a token that is representable in multiple VMs.

### Prerequisites

- [Injective CLI](https://docs.injective.network/docs/getting-started/cli)
- [Foundry](https://book.getfoundry.sh/getting-started/installation)

### Running the workshop

1. Create a new ERC20 token
2. Mint tokens to a user
3. Check balances via CLI
4. Check balances via Foundry cast
5. Interact with WASM contract
6. Query WASM contract state

### Conclusion

We've created an ERC20 tokens that is represented at the same address in both the EVM and WASM VMs, also native state.
17 changes: 17 additions & 0 deletions workshops/erc20-mts/scripts/cli-address.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

echo "Getting Injective address and converting to Ethereum address:"

Comment on lines +1 to +4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add usage check for command-line arguments.
Validate that a key name is provided to avoid silent failures.

if [ $# -lt 1 ]; then
  echo "Usage: $0 <key-name>" >&2
  exit 1
fi
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-address.sh at lines 1 to 4, add a check to
ensure a key name argument is provided when running the script. Insert a
conditional that tests if the number of arguments is less than one, and if so,
print a usage message to standard error and exit with status 1. This prevents
the script from running silently without the required input.

# Get the address from keys show command
INJ_ADDRESS=$(injectived keys show $1 --keyring-backend=test -a)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Quote variable expansions in command invocations.
Prevent word-splitting and globbing by quoting $1 and $INJ_ADDRESS.

-INJ_ADDRESS=$(injectived keys show $1 --keyring-backend=test -a)
+INJ_ADDRESS=$(injectived keys show "$1" --keyring-backend=test -a)

-ETH_ADDRESS=0x$(injectived keys parse $INJ_ADDRESS --output json | jq -r '.bytes')
+ETH_ADDRESS=0x$(injectived keys parse "$INJ_ADDRESS" --output json | jq -r '.bytes')

Also applies to: 12-12

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-address.sh at lines 6 and 12, the variables
$1 and $INJ_ADDRESS are used without quotes, which can cause word-splitting and
globbing issues. Fix this by enclosing these variable expansions in double
quotes in the command invocations to ensure they are treated as single arguments
and prevent unintended behavior.


# Display the Injective address
echo "\t* Injective address: $INJ_ADDRESS"

# Parse the Injective address to get the Ethereum address
ETH_ADDRESS=0x$(injectived keys parse $INJ_ADDRESS --output json | jq -r '.bytes')

# Display the Ethereum address
echo "\t* Ethereum address: $ETH_ADDRESS"

echo ""
15 changes: 15 additions & 0 deletions workshops/erc20-mts/scripts/cli-balances-user1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

source .local.env
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use POSIX-compatible syntax for sourcing environment variables.
Replace source .local.env with . for /bin/sh compatibility.

- source .local.env
+ . .local.env
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
source .local.env
. .local.env
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-balances-user1.sh at line 3, replace the use
of `source .local.env` with `. .local.env` to ensure POSIX-compatible syntax for
sourcing environment variables, making the script compatible with /bin/sh.


echo "Checking balance of user1..."

USER_INJ_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Quote variable expansions in commands.
Wrap $USER in quotes to prevent word-splitting and globbing.

- USER_INJ_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a)
+ USER_INJ_ADDRESS=$(injectived keys show "$USER" --keyring-backend=test -a)
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-balances-user1.sh at line 7, the variable
$USER is used without quotes in the command substitution, which can cause
word-splitting or globbing issues. Fix this by wrapping $USER in double quotes
like "$USER" to ensure it is treated as a single argument and prevent unintended
behavior.


echo "\n### RUNNING ###"
echo injectived q bank balances $USER_INJ_ADDRESS --chain-id $CHAIN_ID --node $INJ_URL
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add keyring-backend and quote variables when querying balances.
Ensure consistent CLI context and handle variables safely.

- echo injectived q bank balances $USER_INJ_ADDRESS --chain-id $CHAIN_ID --node $INJ_URL
+ echo injectived q bank balances "$USER_INJ_ADDRESS" --chain-id "$CHAIN_ID" --node "$INJ_URL" --keyring-backend=test

- injectived q bank balances $USER_INJ_ADDRESS --chain-id $CHAIN_ID --node $INJ_URL
+ injectived q bank balances "$USER_INJ_ADDRESS" --chain-id "$CHAIN_ID" --node "$INJ_URL" --keyring-backend=test

Also applies to: 13-13

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-balances-user1.sh at lines 10 and 13, the
echo commands for querying balances lack the --keyring-backend flag and do not
quote variables, which can cause issues with CLI context and variable safety.
Add the --keyring-backend flag with the appropriate value to the commands and
enclose all variable references in double quotes to ensure consistent CLI
context and safe variable handling.

echo "###############\n"

injectived q bank balances $USER_INJ_ADDRESS --chain-id $CHAIN_ID --node $INJ_URL

echo ""
18 changes: 18 additions & 0 deletions workshops/erc20-mts/scripts/cli-balances-user2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

source .local.env
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use POSIX-compatible syntax for sourcing the environment file.
Replace source .local.env with . to ensure /bin/sh compatibility.

- source .local.env
+ . .local.env
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-balances-user2.sh at line 3, replace the use
of `source .local.env` with `. .local.env` to ensure POSIX-compatible syntax for
sourcing the environment file, making the script compatible with /bin/sh.


echo "Checking balance of user2..."

if [ -z "$USER_INJ_ADDRESS" ]; then
echo "⚠️ Error: USER_INJ_ADDRESS env variable is not set"
exit 1
fi

echo "\n### RUNNING ###"
echo injectived q bank balances $1 --chain-id $CHAIN_ID --node $INJ_URL --keyring-backend=test
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use the environment variable $USER_INJ_ADDRESS instead of positional $1.
The script checks USER_INJ_ADDRESS but then uses $1, causing incorrect behavior.

- echo injectived q bank balances $1 --chain-id $CHAIN_ID --node $INJ_URL --keyring-backend=test
+ echo injectived q bank balances "$USER_INJ_ADDRESS" --chain-id "$CHAIN_ID" --node "$INJ_URL" --keyring-backend=test

- injectived q bank balances $1 --chain-id $CHAIN_ID --node $INJ_URL --keyring-backend=test
+ injectived q bank balances "$USER_INJ_ADDRESS" --chain-id "$CHAIN_ID" --node "$INJ_URL" --keyring-backend=test

Ensure $CHAIN_ID and $INJ_URL are quoted as well.

Also applies to: 16-16

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-balances-user2.sh at lines 13 and 16, replace
the positional parameter $1 with the environment variable $USER_INJ_ADDRESS to
ensure the correct address is used. Additionally, quote the variables $CHAIN_ID
and $INJ_URL in the command to prevent issues with spaces or special characters.
Update both lines accordingly to fix the inconsistent usage and improve
robustness.

echo "###############\n"

injectived q bank balances $1 --chain-id $CHAIN_ID --node $INJ_URL --keyring-backend=test

echo ""
26 changes: 26 additions & 0 deletions workshops/erc20-mts/scripts/cli-denom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

echo "Getting denom..."

source .local.env

Comment on lines +1 to +6
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Switch to Bash for advanced syntax.
This script uses source and [[ ]], which are not POSIX sh features. Either update the shebang to Bash:

-#!/bin/sh
+#!/usr/bin/env bash

or refactor to POSIX-compatible syntax.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/sh
echo "Getting denom..."
source .local.env
#!/usr/bin/env bash
echo "Getting denom..."
source .local.env
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 5-5: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-denom.sh at lines 1 to 6, the script uses
Bash-specific features like 'source' and '[[ ]]' but has a sh shebang. Change
the shebang line from '#!/bin/sh' to '#!/bin/bash' to ensure the script runs
with Bash and supports these features.

# Check if an argument was provided
if [ -z "$1" ]; then
echo "⚠️ Error: No denom specified"
echo "Usage: $0 <denom>"
exit 1
fi

# Check if denom starts with erc20: prefix
if [[ "$1" != erc20:* ]]; then
echo "⚠️ Error: Denom must start with 'erc20:' prefix"
echo "Usage: $0 erc20:<contract_address>"
exit 1
fi

echo "\n### QUERYING DENOM ###"
echo injectived q bank denom-metadata $1 \
--node $INJ_URL
echo "######################\n"

injectived q bank denom-metadata $1 --node $INJ_URL
7 changes: 7 additions & 0 deletions workshops/erc20-mts/scripts/cli-keys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

source .local.env
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use POSIX-compatible syntax for sourcing environment variables.
Replace source .local.env with . to ensure compatibility with /bin/sh.

- source .local.env
+ . .local.env
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
source .local.env
. .local.env
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-keys.sh at line 3, replace the use of `source
.local.env` with `. .local.env` to ensure POSIX compatibility and proper
sourcing of environment variables when the script is run with /bin/sh.


injectived keys $* --keyring-backend=test
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Quote positional parameters to preserve whitespace.
Use "$@" instead of $* to correctly handle arguments containing spaces.

- injectived keys $* --keyring-backend=test
+ injectived keys "$@" --keyring-backend=test
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
injectived keys $* --keyring-backend=test
injectived keys "$@" --keyring-backend=test
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems.

(SC2048)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-keys.sh at line 5, replace the use of $* with
"$@" to ensure that all positional parameters are correctly quoted and
whitespace within arguments is preserved. This change will prevent arguments
with spaces from being split incorrectly when passed to the injectived keys
command.


echo ""
7 changes: 7 additions & 0 deletions workshops/erc20-mts/scripts/cli-q.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

source .local.env
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use POSIX-compatible sourcing

Replace source .local.env with:

- source .local.env
+ . .local.env
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
source .local.env
. .local.env
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-q.sh at line 3, replace the non-POSIX `source
.local.env` command with the POSIX-compatible `. .local.env` syntax to ensure
the script runs correctly in all POSIX-compliant shells.


injectived q $* --node $INJ_URL
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Quote positional parameters

Use "$@" instead of $* to preserve arguments with spaces, and quote $INJ_URL:

- injectived q $* --node $INJ_URL
+ injectived q "$@" --node "$INJ_URL"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
injectived q $* --node $INJ_URL
injectived q "$@" --node "$INJ_URL"
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems.

(SC2048)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-q.sh at line 5, replace the unquoted
positional parameters $* with "$@" to correctly preserve arguments containing
spaces, and also quote the $INJ_URL variable to handle any spaces or special
characters safely. This ensures all arguments are passed accurately to the
injectived command.


echo ""
7 changes: 7 additions & 0 deletions workshops/erc20-mts/scripts/cli-tx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

source .local.env
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use POSIX-compatible sourcing

Replace source .local.env with:

- source .local.env
+ . .local.env
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-tx.sh at line 3, replace the
non-POSIX-compliant `source .local.env` command with the POSIX-compatible `.
.local.env` syntax to ensure compatibility across different shell environments.


injectived tx $* --keyring-backend=test --chain-id $CHAIN_ID --node $INJ_URL --gas=auto --gas-adjustment=1.3 --gas-prices=10inj
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Quote positional parameters

Use "$@" and quote variables to handle whitespace safely:

- injectived tx $* --keyring-backend=test --chain-id $CHAIN_ID --node $INJ_URL --gas=auto --gas-adjustment=1.3 --gas-prices=10inj
+ injectived tx "$@" --keyring-backend=test --chain-id "$CHAIN_ID" --node "$INJ_URL" --gas=auto --gas-adjustment=1.3 --gas-prices=10inj
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 5-5: Use "$@" (with quotes) to prevent whitespace problems.

(SC2048)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/cli-tx.sh at line 5, replace the unquoted
positional parameters $* with the quoted "$@" to correctly handle arguments
containing whitespace. Also, ensure all variables like $CHAIN_ID and $INJ_URL
are enclosed in double quotes to prevent word splitting and globbing issues.


echo ""
48 changes: 48 additions & 0 deletions workshops/erc20-mts/scripts/deploy-erc20-mintburn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh

source .local.env
source scripts/foundry-util.sh
Comment on lines +3 to +4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use POSIX-compatible dot for sourcing
The source builtin isn’t defined in POSIX sh. Replace with . for broader shell compatibility.

- source .local.env
- source scripts/foundry-util.sh
+ . .local.env
+ . scripts/foundry-util.sh
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)


[warning] 4-4: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/deploy-erc20-mintburn.sh at lines 3 to 4, replace
the use of the `source` command with the POSIX-compatible dot `.` command for
sourcing files. Change `source .local.env` to `. .local.env` and `source
scripts/foundry-util.sh` to `. scripts/foundry-util.sh` to ensure compatibility
with POSIX sh shells.


echo "Deploying ERC20 token..."

USER_INJ_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a)
USER_ETH_ADDRESS=0x$(injectived keys parse $USER_INJ_ADDRESS --output json | jq -r '.bytes')

echo "Injective address: $USER_INJ_ADDRESS"
echo "Ethereum address (owner): $USER_ETH_ADDRESS"

echo "\n### RUNNING ###"
echo forge create src/MintBurnBankERC20.sol:MintBurnBankERC20 \
-r $ETH_URL \
--account $USER \
--password $USER_PWD \
--broadcast \
--value 1000000000000000000 \
--gas-limit 10000000 \
--gas-price 10 \
--legacy \
-vvvv \
--json \
--constructor-args $USER_ETH_ADDRESS "TestMeme" "MEME" "18"
echo "###############\n"

create_res=$(forge create src/MintBurnBankERC20.sol:MintBurnBankERC20 \
-r $ETH_URL \
--account $USER \
--password $USER_PWD \
--broadcast \
--value 1000000000000000000 \
--gas-limit 10000000 \
--gas-price 10 \
--legacy \
-vvvv \
--json \
--constructor-args $USER_ETH_ADDRESS "TestMeme" "MEME" "18")
if [ $? -ne 0 ]; then
exit 1
fi
check_foundry_result "$create_res"

contract_eth_address=$(echo $create_res | jq -r '.deployedTo')
echo "ERC20 address: $contract_eth_address"
echo ""
42 changes: 42 additions & 0 deletions workshops/erc20-mts/scripts/deploy-erc20.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

source .local.env
source scripts/foundry-util.sh
Comment on lines +3 to +4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use POSIX-compatible dot for sourcing
Switch source to . to maintain POSIX compliance.

- source .local.env
- source scripts/foundry-util.sh
+ . .local.env
+ . scripts/foundry-util.sh
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
source .local.env
source scripts/foundry-util.sh
. .local.env
. scripts/foundry-util.sh
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)


[warning] 4-4: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/deploy-erc20.sh at lines 3 to 4, replace the use
of the `source` command with the POSIX-compatible dot `.` command for sourcing
files. Change `source .local.env` to `. .local.env` and `source
scripts/foundry-util.sh` to `. scripts/foundry-util.sh` to ensure POSIX
compliance.


echo "Deploying ERC20 token..."

echo "\n### RUNNING ###"
echo forge create src/FixedSupplyBankERC20.sol:FixedSupplyBankERC20 \
-r $ETH_URL \
--account $USER \
--password $USER_PWD \
--broadcast \
--gas-limit 10000000 \
--gas-price 10 \
--value 1000000000000000000 \
--legacy \
-vvvv \
--json \
--constructor-args "TestMeme" "MEME" "18" "1000000000000000000000000000"
echo "###############\n"

create_res=$(forge create src/FixedSupplyBankERC20.sol:FixedSupplyBankERC20 \
-r $ETH_URL \
--account $USER \
--password $USER_PWD \
--broadcast \
--gas-limit 10000000 \
--gas-price 10 \
--value 1000000000000000000 \
--legacy \
-vvvv \
--json \
--constructor-args "TestMeme" "MEME" "18" "1000000000000000000000000000")
if [ $? -ne 0 ]; then
exit 1
fi
check_foundry_result "$create_res"

contract_eth_address=$(echo $create_res | jq -r '.deployedTo')
echo "ERC20 address: $contract_eth_address"
echo ""
133 changes: 133 additions & 0 deletions workshops/erc20-mts/scripts/deploy-wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#!/bin/sh

source .local.env

Comment on lines +1 to +4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Shebang & sourcing are inconsistent – decide on Bash or strict POSIX

source is a Bash-ism but the shebang points to /bin/sh. Either:

-#!/bin/sh
-source .local.env
+#!/usr/bin/env bash
+set -euo pipefail
+. .local.env   # POSIX-portable “source”

or make the script strictly POSIX (. instead of source, avoid Bash-only flags).
Fail-fast flags (set -euo pipefail) are strongly recommended.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/sh
source .local.env
#!/usr/bin/env bash
set -euo pipefail
. .local.env # POSIX-portable “source”
# …rest of your script…
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 3-3: In POSIX sh, 'source' in place of '.' is undefined.

(SC3046)

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/deploy-wasm.sh at lines 1 to 4, the script uses a
shebang for /bin/sh but employs the Bash-specific 'source' command. To fix this,
either change the shebang to /bin/bash to match the use of 'source', or replace
'source' with the POSIX-compliant '.' command and avoid any Bash-only features.
Additionally, add fail-fast flags like 'set -euo pipefail' near the top of the
script to improve robustness.

echo "Deploying and instantiating WASM contract..."

# Get the user's address
USER_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a)

Comment on lines +8 to +9
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Quote variable expansions to avoid word-splitting & injection

Examples:

-USER_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a)
+USER_ADDRESS=$(injectived keys show "$USER" --keyring-backend=test -a)

Apply the same to every $USER, $CHAIN_ID, $INJ_URL, $CODE_ID, $TXHASH, etc.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
USER_ADDRESS=$(injectived keys show $USER --keyring-backend=test -a)
USER_ADDRESS=$(injectived keys show "$USER" --keyring-backend=test -a)
🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/deploy-wasm.sh around lines 8 to 9, variable
expansions like $USER should be quoted to prevent word-splitting and potential
injection issues. Update all instances of variables such as $USER, $CHAIN_ID,
$INJ_URL, $CODE_ID, $TXHASH, etc., by enclosing them in double quotes, for
example, change $USER to "$USER".

echo "\n### RUNNING WASM STORE ###"
echo injectived tx wasm store wasm/counter.wasm \
--from $USER \
--chain-id $CHAIN_ID \
--node $INJ_URL \
--gas-prices 500000000inj \
--gas auto \
--gas-adjustment 1.3 \
--broadcast-mode sync \
--keyring-backend test \
--output json \
-y
echo "########################\n"

store_res=$(injectived tx wasm store wasm/counter.wasm \
--from $USER \
--chain-id $CHAIN_ID \
--node $INJ_URL \
--gas-prices 500000000inj \
--gas auto \
--gas-adjustment 1.3 \
--broadcast-mode sync \
--keyring-backend test \
-y --output json)
if [ $? -ne 0 ]; then
echo "Failed to store WASM contract"
exit 1
fi

# Extract txhash from store transaction response
TXHASH=$(echo $store_res | jq -r '.txhash')
echo "Transaction hash: $TXHASH"

sleep 3

echo "\n### QUERYING TRANSACTION ###"
echo injectived q tx $TXHASH \
--node $INJ_URL \
--chain-id $CHAIN_ID \
--output json
echo "########################\n"

# Query the transaction to get the actual results
tx_result=$(injectived q tx $TXHASH \
--node $INJ_URL \
--chain-id $CHAIN_ID \
--output json)
if [ $? -ne 0 ]; then
echo "Failed to query transaction"
exit 1
fi

# Update store_res with the full transaction result
store_res=$tx_result

# Extract code ID from transaction response
CODE_ID=$(echo $store_res | jq -r '.events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value')
echo "Contract Code ID: $CODE_ID"

Comment on lines +63 to +68
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Gracefully abort when CODE_ID / CONTRACT_ADDRESS is empty

If jq fails to locate the attribute the variables become empty strings, leading to confusing downstream errors. Add a guard:

if [ -z "$CODE_ID" ]; then
  echo "❌ Unable to extract code_id from transaction."
  exit 1
fi

Repeat for CONTRACT_ADDRESS.

Also applies to: 130-133

🤖 Prompt for AI Agents
In workshops/erc20-mts/scripts/deploy-wasm.sh around lines 63 to 68, add a check
after extracting CODE_ID to verify if it is empty. If CODE_ID is empty, print an
error message and exit the script with a non-zero status to prevent confusing
downstream errors. Similarly, add the same kind of check for CONTRACT_ADDRESS
around lines 130 to 133 to ensure the script aborts gracefully if
CONTRACT_ADDRESS is not found.

sleep 2

echo "\n### RUNNING WASM INSTANTIATE ###"
echo injectived tx wasm instantiate $CODE_ID '{"count":0}' \
--label "counter-1.0.0" \
--admin $USER_ADDRESS \
--from $USER \
--chain-id $CHAIN_ID \
--node $INJ_URL \
--gas-prices 500000000inj \
--gas auto \
--gas-adjustment 1.3 \
--broadcast-mode sync \
--keyring-backend test \
--output json \
-y
echo "############################\n"

instantiate_res=$(injectived tx wasm instantiate $CODE_ID '{"count":0}' \
--label "counter-1.0.0" \
--admin $USER_ADDRESS \
--from $USER \
--chain-id $CHAIN_ID \
--node $INJ_URL \
--gas-prices 500000000inj \
--gas auto \
--gas-adjustment 1.3 \
--broadcast-mode sync \
--keyring-backend test \
-y --output json)
if [ $? -ne 0 ]; then
echo "Failed to instantiate WASM contract"
exit 1
fi

# Extract txhash from instantiate transaction response
TXHASH=$(echo $instantiate_res | jq -r '.txhash')
echo "Transaction hash: $TXHASH"

sleep 3

echo "\n### QUERYING TRANSACTION ###"
echo injectived q tx $TXHASH \
--node $INJ_URL \
--chain-id $CHAIN_ID \
--output json
echo "########################\n"

# Query the transaction to get the actual results
tx_result=$(injectived q tx $TXHASH \
--node $INJ_URL \
--chain-id $CHAIN_ID \
--output json)
if [ $? -ne 0 ]; then
echo "Failed to query transaction"
exit 1
fi

# Update instantiate_res with the full transaction result
instantiate_res=$tx_result

# Extract contract address from instantiation response
CONTRACT_ADDRESS=$(echo $instantiate_res | jq -r '.events[] | select(.type=="instantiate") | .attributes[] | select(.key=="_contract_address") | .value')
echo "Contract address: $CONTRACT_ADDRESS"
echo ""
Loading