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.
Modify the Scripts
To modify the hello-world scripts to deploy your smart contract:
From the command line, navigate to the hello-world folder in the WAX Blockchain Source Code Repository:
cd wax-blockchain/samples/hello-world
Copy the contents of hello-world to your smart contract's directory. For this example, we'll use wax_deploy.
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.
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.
<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:
Build your smart contract. In the command line, run the following script from the wax_deploy folder:
make build
This creates
wax.wasm
andwax.abi
in the wax_deploy folder.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).
Create a WAX Contract Account. To create a blockchain account for your smart contract, run:
Parameter Example Description WAX_ACCOUNT waxprimary Your dApp Developer Account name. WAX_PRIVATE_KEY 5JTZaN1zabi5wyC3LcdeZG3AzF7sLDX4JFqMDe68ThLC3Q5nYez Private key for your dApp Developer Account. CONTRACT_ACCOUNT waxsc1 Specify 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_KEY EOS4yxqE5KYv5XaB2gj6sZTUDiGzKm42KfiRPDCeXWZUsAZZVXk1F New 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
Deploy your contract. From the command line, run:
Parameter Example Description CONTRACT_ACCOUNT waxsc1 The name you specified for your smart contract's account. CONTRACT_PRIVATE_KEY 9X5KRXKVx25yjL3FvxxY9YxYxxYY9Yxx99yyXTRH8DjppKpD9tKtVz Private 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.
Test your smart contract. From the command line, run:
make test CONTRACT_ACCOUNT=waxsc1
Your dApp is now live on WAX!