WAX-CDT Deploy
In this guide, you'll use the cleos set contract
command to deploy your smart contract to the WAX mainnet.
Before you begin, you'll need to compile your smart contract and have your WASM and ABI files ready. Refer to Smart Contract Quickstartor WAX-CDT Build Toolsfor more information.
You'll also need to:
- Create a self-managed WAX Blockchain Account.
- Make sure you have enough WAX staked in your account to allocate resources.
To deploy your smart contract to the WAX mainnet:
Open and unlock your wallet.
cleos wallet open -n mywallet && cleos wallet unlock -n mywallet --password {wallet.pwd}
Generate a public/private key pair that's used to create your smart contract's blockchain account. From the command line, use the
cleos create key
command:cleos wallet create_key -n mywallet
tipNote: You can also use an EOSIO compatible wallet (e.g., Scatter).From the command line, use
cleos system newaccount
to create your smart contract's account. To run this command, you'll need to have the proper authority. This means that the wallet containing your primary account must be opened and unlocked.Parameter Example Description -u -u chain-api-url This is the WAX Blockchain URL. system system Sends the system contract action to the WAX Blockchain. newaccount newaccount Command to create a new account. primaryAccount waxdappacct1 Your self-managed WAX Blockchain Account with staked WAX tokens. contractAccount HelloWorld10 Name of your smart contract's account. Exactly 12 characters from (a-z1-5). newPublicKey EOS7jEb46pDiWvA39faCoFn3jUdn6LfL51irdXbvfpuSko86iNU5x This is the public key you created in Step 1. stake-net --stake-net '0.50000000 WAX' Amount of WAX to stake for NET. stake-cpu --stake-cpu '0.50000000 WAX' Amount of WAX to allocate for CPU. buy-ram-kbytes --buy-ram-kbytes 32 Amount of RAM to allocate. Example
cleos -u chain-api-url system newaccount waxdappacct1 HelloWorld10 EOS7jEb46pDiWvA39faCoFn3jUdn6LfL51irdXbvfpuSko86iNU5x --stake-net '0.50000000 WAX' --stake-cpu '0.50000000 WAX' --buy-ram-kbytes 32
tipNote: You'll need to repeat Steps 1 and 2 for each of your contracts.Deploy. From the command line, set your contract with the
cleos set contract
command:Parameter Example Description -u -u chain-api-url This is the WAX Blockchain URL. contractAccount HelloWorld10 Your smart contract's account (created in Step 2). fullPath d/wax-blockchain/wax-cdt/mycontracts/wax/build The full path to your WASM and ABI files. wasmName wax Name of your WASM file. abiName wax Name of your ABI file. cleos -u chain-api-url set contract HelloWorld10 d/wax-blockchain/wax-cdt/mycontracts/wax/build wax.wasm wax.abi
Your dApp is now live on WAX!