Skip to main content

Docker Deploy

In this guide, you'll learn how to customize the hello-world build scripts to deploy your smart contracts to the WAX mainnet.

Before you begin:

  • Make sure Docker is configured to run without sudo.
  • Download the WAX Blockchain Source Code. Refer to the WAX Blockchain Setupfor more information.
  • Have your WAX Blockchain Account public/private keys available.
  • Make sure you have enough WAX staked in your account to allocate resources.
tip
Note: You do not need to build WAX source code to complete these steps.

Modify the Scripts

To modify the hello-world scripts to deploy your smart contract:

  1. From the command line, navigate to the hello-world folder in the WAX Blockchain Source Code Repository:

    cd wax-blockchain/samples/hello-world
  2. Copy the contents of hello-world to your smart contract's directory. For this example, we'll use wax_deploy.

  3. From wax_deploy, open CMakeLists.txt. This file stores your project name and smart contract file name.

    a. Type your contract name on line 25.

    project(waxcontract)

    b. Type your contract's filename on line 29.

    add_contract(${PROJECT_NAME} ${PROJECT_NAME} waxcontract.cpp)

    Save the file.

  4. Next, open Makefile. This file contains the scripts to run cleos and the WAX Docker Development image.

    a. Type your contract name on Line 23.

    CONTRACT_NAME = waxcontract

    b. Update the WAX allocations for your smart contract on Line 87, if required.

    --stake-net '0.50000000 WAX' --stake-cpu '0.50000000 WAX' --buy-ram-kbytes 32"

    c. To test your smart contract, you can update line 48 to run your action:

    push action ${CONTRACT_ACCOUNT} greet '[]' -p ${CONTRACT_ACCOUNT}@active"

    Save the file.

tip
<strong>Note:</strong> `NODEOS_URL` is the only optional parameter. Its default value is the mainnet deployment address [chain-api-url](/docs/wax-infrastructure/#public-and-free-api-service-providers/.  
:::

Once these changes have been made, you're ready to use the make scripts to build and deploy your smart contract.

Deploy Your Smart Contract

To launch your WAX smart contract on the WAX Blockchain:

  1. Build your smart contract. In the command line, run the following script from the wax_deploy folder:

    make build

    This creates wax.wasm and wax.abi in the wax_deploy folder.

  2. Generate keys for your smart contract's account. From the command line, run:

    make create-key

    This creates a pair of private/public keys for your smart contract's account (save the console response in a safe place, you'll need to use them later).

  3. Create a WAX Contract Account. To create a blockchain account for your smart contract, run:

    ParameterExampleDescription
    WAX_ACCOUNTwaxprimaryYour dApp Developer Account name.
    WAX_PRIVATE_KEY5JTZaN1zabi5wyC3LcdeZG3AzF7sLDX4JFqMDe68ThLC3Q5nYezPrivate key for your dApp Developer Account.
    CONTRACT_ACCOUNTwaxsc1Specify a new name for your smart contract account. Account names must be less than 13 characters and only contain letters [a-z] and numbers [1-5].
    CONTRACT_PUBLIC_KEYEOS4yxqE5KYv5XaB2gj6sZTUDiGzKm42KfiRPDCeXWZUsAZZVXk1FNew public key that you created in Step 2.
    make create-account WAX_ACCOUNT=waxprimary WAX_PRIVATE_KEY=5JTZaN1zabi5wyC3LcdeZG3AzF7sLDX4JFqMDe68ThLC3Q5nYez CONTRACT_ACCOUNT=waxsc1 CONTRACT_PUBLIC_KEY=EOS4yxqE5KYv5XaB2gj6sZTUDiGzKm42KfiRPDCeXWZUsAZZVXk1F
  4. Deploy your contract. From the command line, run:

    ParameterExampleDescription
    CONTRACT_ACCOUNTwaxsc1The name you specified for your smart contract's account.
    CONTRACT_PRIVATE_KEY9X5KRXKVx25yjL3FvxxY9YxYxxYY9Yxx99yyXTRH8DjppKpD9tKtVzPrivate key for your smart contract's account (that you created in Step 2).
    make deploy CONTRACT_ACCOUNT=waxsc1 CONTRACT_PRIVATE_KEY=9X5KRXKVx25yjL3FvxxY9YxYxxYY9Yxx99yyXTRH8DjppKpD9tKtVz

    This deploys your smart contract to the mainnet. You only need to pass your smart contract's account name and private key.

  5. Test your smart contract. From the command line, run:

    make test CONTRACT_ACCOUNT=waxsc1

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. :::