mega deploy

The deploy command (also aliased as mega create) deploys smart contracts to either a local development network or the Mega testnet.

Usage

mega deploy <contract> [options]

Arguments

ArgumentDescription
contractPath to the contract file and contract name (e.g., src/MyContract.sol:MyContract)

Options

OptionDescription
--testnetDeploy to Mega testnet instead of local network
--broadcastBroadcast the transaction instead of doing a dry run
--constructor-args [args...]The constructor arguments
--verifyVerify contract after creation
--account <name>Use a keystore account from the default keystores folder
--private-key <key>Use the provided private key
--gas-limit <limit>Gas limit for the transaction
--value <value>Ether to send in the transaction
--optimizeActivate the Solidity optimizer when deploying

This command supports all options available in forge create. See the Forge documentation for a complete list.

Description

This command deploys Solidity smart contracts to a blockchain network. By default, it deploys to a local Anvil network, but you can use the --testnet flag to deploy to the Mega testnet.

The command is a wrapper around Foundry’s forge create with additional features specific to the Mega ecosystem.

Examples

Deploy to local network (dry run)

mega deploy src/MyContract.sol:MyContract

Deploy to local network and broadcast the transaction

mega deploy src/MyContract.sol:MyContract --broadcast

Deploy to Mega testnet using a stored account

mega deploy src/MyContract.sol:MyContract --testnet --broadcast --account <account-name>

Deploy to Mega testnet using a private key

mega deploy src/MyContract.sol:MyContract --testnet --broadcast --private-key <private-key>

Deploy with constructor arguments

mega deploy src/MyContract.sol:MyContract --broadcast --constructor-args "Hello World" 123
  • compile - Compile contracts before deployment
  • account - Manage accounts for deployment
  • balance - Check balance before deployment