This guide provides step-by-step instructions to deploy a C++ smart contract to the WAX blockchain.
- Install EOSIO software: You need the EOSIO software installed on your system.
- Install Nodeos: Nodeos is the core service daemon that runs an EOSIO blockchain.
- Install CMake: CMake is used to build the smart contract.
- Install CDT (Contract Development Toolkit): EOSIO.CDT is a suite of tools used to build EOSIO smart contracts.
- Set up a local or testnet environment using Nodeos.
- Create a WAX account and obtain WAX tokens for deployment fees.
Write your smart contract in C++. Ensure it follows EOSIO standards. Example:
#include <eosio/eosio.hpp>
using namespace eosio;
class [[eosio::contract]] example : public contract {
public:
using contract::contract;
[[eosio::action]]
void hi(name user) {
print("Hello, ", user);
}
};
EOSIO_DISPATCH(example, (hi))Use EOSIO.CDT to compile the smart contract.
eosio-cpp -o example.wasm example.cpp --abigenDeploy the contract using Cleos (command-line tool for interacting with EOSIO-based blockchains).
cleos -u https://testnet.waxsweden.org set contract <account> <path_to_compiled_contract>Interact with the contract using Cleos or any other tool that allows interaction with the blockchain.
cleos -u https://testnet.waxsweden.org push action youraccount hi '["yourwaxaccount"]' -p youraccount@active- EOSIO.CDT (Contract Development Toolkit): A comprehensive suite for developing EOSIO-based smart contracts.
- Cleos: Command-line interface for interacting with EOSIO-based blockchains.
- EOS Studio: An integrated development environment (IDE) specifically for EOSIO smart contract development.
- Scatter: A wallet and toolkit that can be used for development.
- Bloks.io: A block explorer and interface that provides interaction capabilities.
- Ensure you replace
<account>and<path_to_compiled_contract>with your actual account name and path to the compiled contract file. - For more information and detailed documentation, refer to the EOSIO Documentation.
-
How to Build -
- cd to 'build' directory
- run the command 'cmake ..'
- run the command 'make'
-
After build -
- The built smart contract is under the 'waxel' directory in the 'build' directory
- You can then do a 'set contract' action with 'cleos' and point in to the './build/waxel' directory
-
Additions to CMake should be done to the CMakeLists.txt in the './src' directory and not in the top level CMakeLists.txt
Generated on {datetime.now().strftime('%Y-%m-%d')}