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 Quickstart or WAX-CDT Build Tools for more information.

You’ll also need to:

  • Create a free 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:

  1. Create keys. First, you’ll need to 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   
    
    Note: You can also use an EOSIO compatible wallet (e.g., Scatter).
  2. Create a WAX Contract Account. From the command line, use cleos system newaccount with the following parameters.

    Parameter Example Description
    -u -u https://chain.wax.io 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 dAppWAXacct1 Your primary WAX Blockchain Account, with staked WAX tokens.
    contractAccount HelloWorld10 Name of your smart contract’s account. Exactly 12 characters from (a-z1-5).
    contractAccountPublicKey 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 https://chain.wax.io system newaccount dAppWAXacct1 HelloWorld10 EOS7jEb46pDiWvA39faCoFn3jUdn6LfL51irdXbvfpuSko86iNU5x --stake-net '0.50000000 WAX' --stake-cpu '0.50000000 WAX' --buy-ram-kbytes 32
    
    Note: You'll need to repeat Steps 1 and 2 for each of your contracts.
  3. Deploy. From the command line, set your contract with the cleos set contract command:

    Parameter Example Description
    -u -u https://chain.wax.io 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 https://chain.wax.io set contract HelloWorld10 d/wax-blockchain/wax-cdt/mycontracts/wax/build wax.wasm wax.abi
    

Your dApp is now live on WAX!

Note: Depending on how your dApp's onboarding process is built, your customers may need to create a WAX Account to use your dApp on WAX.