Skip to content
5 changes: 5 additions & 0 deletions cli-typescript/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export enum SUPPORTED_CHAINS {
ABSTRACT = 2741,
BERACHAIN = 80094,
MONAD_TESTNET = 10143,
MEGAETH_TESTNET = 6342,
}

export const supportedChainNames: { [key in SUPPORTED_CHAINS]: string } = {
Expand All @@ -88,6 +89,7 @@ export const supportedChainNames: { [key in SUPPORTED_CHAINS]: string } = {
[SUPPORTED_CHAINS.ABSTRACT]: 'abstract',
[SUPPORTED_CHAINS.BERACHAIN]: 'berachain',
[SUPPORTED_CHAINS.MONAD_TESTNET]: 'monadTestnet',
[SUPPORTED_CHAINS.MEGAETH_TESTNET]: 'megaethTestnet',
};

export const rpcUrls: { [chainId in SUPPORTED_CHAINS]: string } = {
Expand All @@ -113,6 +115,8 @@ export const rpcUrls: { [chainId in SUPPORTED_CHAINS]: string } = {
'https://evm-router.magiceden.io/monad/testnet/me2024', // Monad Testnet
[SUPPORTED_CHAINS.AVALANCHE]:
'https://evm-router.magiceden.io/avalanche/mainnet/me2024', // Avalanche
[SUPPORTED_CHAINS.MEGAETH_TESTNET]:
'https://evm-router.magiceden.io/megaeth/testnet/me2024', // MegaETH Testnet
};

export const explorerUrls: { [chainId in SUPPORTED_CHAINS]: string } = {
Expand All @@ -128,6 +132,7 @@ export const explorerUrls: { [chainId in SUPPORTED_CHAINS]: string } = {
[SUPPORTED_CHAINS.BERACHAIN]: 'https://berascan.com', // Berachain
[SUPPORTED_CHAINS.MONAD_TESTNET]: 'https://testnet.monadexplorer.com', // Monad Testnet
[SUPPORTED_CHAINS.AVALANCHE]: 'https://subnets.avax.network/', // Avalanche
[SUPPORTED_CHAINS.MEGAETH_TESTNET]: 'https://megaexplorer.xyz', // MegaETH Testnet
};

export const DEFAULT_TOKEN_URI_SUFFIX = '.json';
Expand Down
7 changes: 7 additions & 0 deletions cli/cmds/common
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ set_cosigner_address() {
fi
}

set_mint_fee() {
show_title "$title" "> Enter mint fee <"
mint_fee=$(gum input --placeholder "Enter a decimal mint fee (e.g. 0.0001)")
check_input "$mint_fee" "mint fee"
clear
}

set_timestamp_expiry() {
if is_unset_or_null "$timestamp_expiry"; then
show_title "$title" "> Enter the timestamp expiry <"
Expand Down
29 changes: 8 additions & 21 deletions cli/cmds/const
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SUPPORTED_CHAINS=(
"2741:Abstract"
"80094:Berachain"
"10143:MonadTestnet"
"6342:MegaETHTestnet"
)

MAGIC_DROP_KEYSTORE="MAGIC_DROP_KEYSTORE"
Expand All @@ -38,42 +39,28 @@ DEFAULT_IMPL_ID="0"
get_factory_address() {
# abstract factory address
if [ "$chain_id" == "2741" ]; then
echo "0x4a08d3F6881c4843232EFdE05baCfb5eAaB35d19"
elif [ "$chain_id" == "43114" ]; then
echo "0x0b49bDcf2eC9329Fa6F42DCCC66e8906a3E4ACF0"
echo "0x01c1C2f5271aDeA338dAfba77121Fc20B5176620"
else # default
echo "0x000000009e44eBa131196847C685F20Cd4b68aC4"
echo "0x00000000bEa935F8315156894Aa4a45D3c7a0075"
fi
}

get_registry_address() {
# abstract registry address
if [ "$chain_id" == "2741" ]; then
echo "0x9b60ad31F145ec7EE3c559153bB57928B65C0F87"
elif [ "$chain_id" == "43114" ]; then
echo "0x09E0135dfBb7528D6eAA5beB69f3C030dF26F57c"
echo "0x17c9921D99c1Fa6d3dC992719DA1123dCb2CaedA"
else # default
echo "0x00000000caF1E3978e291c5Fb53FeedB957eC146"
echo "0x000000000e447e71b2EC36CD62048Dd2a1Cd0a57"
fi
}

# The latest MagicDrop v1.0.1 implementation ID for each supported chain.
get_impl_id() {
if [ "$token_standard" == "ERC721" ] && [ "$use_erc721c" == "true" ]; then
if [ "$chain_id" == "2741" ]; then
echo "7" # ERC721C implementation ID / abstract
elif [ "$chain_id" == "8453" ]; then
echo "11" # base
elif [ "$chain_id" == "1" ]; then
echo "10" # ethereum
elif [ "$chain_id" == "80094" ]; then
echo "5" # berachain
elif [ "$chain_id" == "10143"]; then
echo "5" # monad testnet
elif [ "$chain_id" == "43114" ]; then
echo "6" # avalanche
if [ "$chain_id" == "6342" ]; then
echo "2" # 721C implementation ID for MegaETH Testnet
else
echo "8" # all other chains
echo "7" # 721C implementation ID on all chains
fi
else
echo $DEFAULT_IMPL_ID
Expand Down
67 changes: 62 additions & 5 deletions cli/cmds/contract
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ deploy_contract() {
value="--value $deployment_fee"
fi

echo "Fetching mint fee..."
mint_fee=$(cast call $registry_address "getMintFee(uint8,uint32)" $standard_id $impl_id --rpc-url "$RPC_URL" $password)
if [ "$mint_fee" == "0" ]; then
value="--value $mint_fee"
fi

confirm_deployment

echo "Deploying contract... this may take a minute."
Expand All @@ -50,7 +56,7 @@ deploy_contract() {

print_transaction_hash

sig_event=$(cast sig-event "NewContractInitialized(address,address,uint32,uint8,string,string)")
sig_event=$(cast sig-event "NewContractInitialized(address,address,uint32,uint8,string,string,uint256)")
event_data=$(get_contract_address_from_logs "$output" "$sig_event")
chunks=($(echo "$event_data" | fold -w64))
contract_address=$(decode_address "${chunks[0]}")
Expand Down Expand Up @@ -80,6 +86,11 @@ deploy_contract() {
if gum confirm "Would you like to setup the contract?"; then
setup_contract
fi

# ask if they would like to set the mint fee now
if gum confirm "Would you like to set the mint fee?"; then
set_mint_fee_contract
fi
}

supports_icreatortoken() {
Expand Down Expand Up @@ -201,9 +212,9 @@ setup_contract() {
password=$(get_password_if_set)

if [ "$token_standard" == "ERC1155" ]; then
setup_selector="setup(string,uint256[],uint256[],address,address,(uint80[],uint80[],uint32[],bytes32[],uint24[],uint256,uint256)[],address,uint96)"
setup_selector="setup(string,uint256[],uint256[],address,address,(uint80[],uint32[],bytes32[],uint24[],uint256,uint256)[],address,uint96)"
elif [ "$token_standard" == "ERC721" ]; then
setup_selector="setup(string,string,uint256,uint256,address,address,(uint80,uint80,uint32,bytes32,uint24,uint256,uint256)[],address,uint96)"
setup_selector="setup(string,string,uint256,uint256,address,address,(uint80,uint32,bytes32,uint24,uint256,uint256)[],address,uint96)"
else
echo "Unknown token standard"
exit 1
Expand Down Expand Up @@ -448,9 +459,9 @@ set_stages_contract() {

if gum confirm "Do you want to proceed?"; then
if [ "$token_standard" == "ERC1155" ]; then
set_stages_selector="setStages((uint80[],uint80[],uint32[],bytes32[],uint24[],uint256,uint256)[])"
set_stages_selector="setStages((uint80[],uint32[],bytes32[],uint24[],uint256,uint256)[])"
elif [ "$token_standard" == "ERC721" ]; then
set_stages_selector="setStages((uint80,uint80,uint32,bytes32,uint24,uint256,uint256)[])"
set_stages_selector="setStages((uint80,uint32,bytes32,uint24,uint256,uint256)[])"
else
echo "Unknown token standard"
exit 1
Expand All @@ -475,6 +486,52 @@ set_stages_contract() {
fi
}

set_mint_fee_contract() {
clear
trap "echo 'Exiting...'; exit 1" SIGINT

title="Set Mint Fee"

set_chain
set_contract_address
set_mint_fee

echo ""
echo "You are about to set the mint fee of $(format_address $contract_address) to $mint_fee"
echo ""

print_signer_with_balance $chain_id

if gum confirm "Do you want to proceed?"; then
set_mint_fee_selector="setMintFee(uint256)"
password=$(get_password_if_set)

echo "Setting mint fee... this will take a moment."

# Add error handling for parse_mint_fee
parsed_mint_fee=$(parse_mint_fee "$mint_fee")
if [ $? -ne 0 ]; then
echo "Error: Failed to parse mint fee"
exit 1
fi
echo "Parsed mint fee: $parsed_mint_fee"

output=$(cast send $contract_address \
"$set_mint_fee_selector" \
"$parsed_mint_fee" \
$password \
$(zksync_flag) \
--chain-id $chain_id \
--rpc-url "$RPC_URL" \
--json)

print_transaction_hash
else
echo "Set mint fee cancelled."
echo ""
fi
}

set_cosigner_contract() {
clear
trap "echo 'Exiting...'; exit 1" SIGINT
Expand Down
1 change: 1 addition & 0 deletions cli/cmds/display
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ confirm_deployment() {
fi
echo "Chain ID: $(gum style --foreground 212 "$chain_id")"
echo "Deployment Fee: $(gum style --foreground 212 "$deployment_fee")"
echo "Mint Fee: $(gum style --foreground 212 "$mint_fee")"
echo "============================================================"
echo ""

Expand Down
4 changes: 4 additions & 0 deletions cli/cmds/main_menu
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ contract_management_menu() {
"Set Base URI (ERC721 Only)" \
"Set URI (ERC1155 Only)" \
"Set Stages" \
"Set Mint Fee" \
"Set Royalties" \
"Set Global Wallet Limit" \
"Set Max Mintable Supply" \
Expand Down Expand Up @@ -94,6 +95,9 @@ contract_management_menu() {
"Set Stages")
set_stages_contract
;;
"Set Mint Fee")
set_mint_fee_contract
;;
"Set Timestamp Expiry")
set_timestamp_expiry_contract
;;
Expand Down
14 changes: 14 additions & 0 deletions cli/cmds/utils
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set_rpc_url() {
80094) RPC_URL="https://rpc.berachain.com" ;; # Berachain
10143) RPC_URL="https://testnet-rpc.monad.xyz" ;; # Monad Testnet
43114) RPC_URL="https://api.avax.network/ext/bc/C/rpc" ;; # Avalanche
6342) RPC_URL="https://carrot.megaeth.com/rpc" ;; # MegaETH Testnet
*) echo "Unsupported chain id"; exit 1 ;;
esac

Expand All @@ -39,6 +40,7 @@ chain_id_to_symbol() {
80094) echo "BERA" ;;
10143) echo "MON" ;;
43114) echo "AVAX" ;;
6342) echo "ETH" ;;
*) echo "Unknown" ;;
esac
}
Expand All @@ -58,6 +60,7 @@ chain_id_to_explorer_url() {
80094) echo "https://berascan.com" ;;
10143) echo "https://testnet.monadexplorer.com" ;;
43114) echo "https://snowtrace.io" ;;
6342) echo "https://megaexplorer.xyz" ;;
*) echo "Unknown" ;;
esac
}
Expand Down Expand Up @@ -95,6 +98,17 @@ process_stages() {
fi
}

parse_mint_fee() {
parsed_mint_fee=$(npx ts-node "$BASE_DIR/../../scripts/utils/parseMintFee.ts" "$mint_fee")

if [[ $? -ne 0 ]]; then
echo "Error: Failed to parse mint fee"
exit 1
fi

echo "$parsed_mint_fee"
}

get_contract_address_from_logs() {
local deployment_data="$1"
local event_sig="$2"
Expand Down
3 changes: 0 additions & 3 deletions cli/collections/example/erc1155_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@
"stages": [
{
"price": ["0.0069"],
"mintFee": ["0.0001"],
"walletLimit": [5],
"startTime": "2024-11-04T16:30:00Z",
"endTime": "2024-11-07T16:25:00Z"
},
{
"price": ["0.0042"],
"mintFee": ["0.0001"],
"walletLimit": [5],
"maxStageSupply": [420],
"startTime": "2024-11-07T16:30:00Z",
"endTime": "2024-12-09T16:00:00Z"
},
{
"price": ["0.069"],
"mintFee": ["0.0001"],
"walletLimit": [5],
"maxStageSupply": [69],
"startTime": "2024-12-09T16:05:00Z",
Expand Down
3 changes: 0 additions & 3 deletions cli/collections/example/erc721_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,19 @@
"stages": [
{
"price": "0.0069",
"mintFee": "0.0001",
"walletLimit": 5,
"startTime": "2024-11-04T16:30:00Z",
"endTime": "2024-11-07T16:25:00Z"
},
{
"price": "0.0042",
"mintFee": "0.0001",
"walletLimit": 5,
"maxStageSupply": 420,
"startTime": "2024-11-07T16:30:00Z",
"endTime": "2024-12-09T16:00:00Z"
},
{
"price": "0.069",
"mintFee": "0.0001",
"walletLimit": 5,
"maxStageSupply": 69,
"startTime": "2024-12-09T16:05:00Z",
Expand Down
1 change: 0 additions & 1 deletion cli/collections/template/erc1155_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"stages": [
{
"price": [""],
"mintFee": [""],
"walletLimit": [0],
"startTime": "2024-11-04T16:30:00Z",
"endTime": "2024-11-07T16:25:00Z"
Expand Down
1 change: 0 additions & 1 deletion cli/collections/template/erc721_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"stages": [
{
"price": "",
"mintFee": "",
"walletLimit": 0,
"startTime": "2024-11-04T16:30:00Z",
"endTime": "2024-11-07T16:25:00Z"
Expand Down
13 changes: 13 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ const config: HardhatUserConfig = {
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
megaeth_testnet: {
url: process.env.MEGAETH_TESTNET_URL || 'https://carrot.megaeth.com/rpc',
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
Expand Down Expand Up @@ -175,6 +180,14 @@ const config: HardhatUserConfig = {
browserURL: 'https://snowtrace.io/'
},
},
{
network: 'megaeth_testnet',
chainId: 6342,
urls: {
apiURL: 'https://www.oklink.com/api/v5/explorer/contract/verify-source-code-plugin/megaeth-testnet',
browserURL: 'https://megaexplorer.xyz/'
},
},
]
},
sourcify: {
Expand Down
1 change: 1 addition & 0 deletions scripts-foundry/common/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ VERIFICATION_API_KEY_BERACHAIN=
VERIFICATION_API_KEY_MONAD_TESTNET=
VERIFICATION_API_KEY_ABSTRACT=
VERIFICATION_API_KEY_AVALANCHE=
VERIFICATION_API_KEY_MEGAETH_TESTNET=

# Deployment Configuration
PRIVATE_KEY=
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if [ $ZK_SYNC ]; then
usage
fi
else
if [ -z "$CHAIN_ID" ] || [ -z "$REGISTRY_SALT" ] || [ -z "$REGISTRY_EXPECTED_ADDRESS"]; then
if [ -z "$CHAIN_ID" ] || [ -z "$REGISTRY_SALT" ] || [ -z "$REGISTRY_EXPECTED_ADDRESS" ]; then
usage
fi
fi
Expand Down
Loading