Cronos Play C++ SDK
Cronos Play C++ API Reference
API Reference can be found:
Pre-requisites
python 3.8 or newer
rust 1.61 or newer
C++ 14 or newer
Optional:
GNU make
GNU make for mac and linux, ninja for windows
Visual Studio 2019 or newer for windows
Pre-built Download
Please download the archive file based on your OS in the release page, where:
Visual Studio 2019 MSVC, x86_64, toolset 14.29 or newer:
play_cpp_sdk_Windows_x86_64.zip
macOS 10.15 or newer:
play_cpp_sdk_Darwin_x86_64.tar.gz
Ubuntu 20.04 or newer:
play_cpp_sdk_libstdc++_Linux_x86_64.tar.gz
orplay_cpp_sdk_libc++_Linux_x86_64.tar.gz
Android:
play_cpp_sdk_$(TARGET)-$(NDK_VERSION).tar.gz
IOS:
play_cpp_sdk_aarch64-apple-ios.tar.gz
Setup a demo project
Windows
Visual Studio Project
Start with a C++ project with .sln
and .vcxproj
files:
Clone the current repository
Unzip the archive file into
demo
folder, and replace the originalsdk
folderOpen
demo.sln
which includes two projects:demo
(dynamic build) anddemostatic
(static build). If you use Visual Studio 2022, retarget project, and upgrade PlatformToolset to v143.Select
Release
profile.Right click
demo
ordemostatic
project, clickBuild
orRebuild
to build the project
CMake Project
Build modern, cross-platform C++ apps that don't depend on .sln
or .vcxproj
files:
Open Visual Studio, then open a local folder in welcome window (or click
File
>Open
>Folder...
in the menu), locate thedemo
folder and open itSelect configuration
x64-Release
in the tool barClick
Build
>Build All
orRebuild All
to build the project
Mac
Clone the current repository
Unzip the archive file into
demo
folder, and replace the originalsdk
folderUnder
demo
folder and build thedemo
project
Linux
Clone the current repository
Unzip the archive file into
demo
folder, and replace the originalsdk
folderUnder
demo
folder and build thedemo
project with g++, clang++ or default compiler
Setup a c++ 14 (or newer) project
Unzip the archive file into the root folder of your project, you should see a folder named
sdk
and its subdirectories/files.
Include the following headers and use the namespaces in your source codes based on your need
Link the
play_cpp_sdk
static or dynamic library,cxxbridge1
static library, and sources (*.cc) into your build system (Visual Studio solution, CMake or Makefile). For more details, check out Cronos Play Docs.
Build libraries and bindings from scratch
If the Pre-built release does not support your platform, you can build the binaries and bindings on your own.
Windows
Run
windows_build.bat
in x64 Native Tools Command Prompt for VS 2019. It will clone necessary submodules, buildplay-cpp-sdk
crate, finally setup and build the demo project.Clean
~/.cargo/git/checkouts
if cxx fails to build, then runwindows_build.bat
again.Run
windows_install.bat
, libraries and bindings will be copied into a new created folder:install
Notes about Visual Studio 2022
Open
demo.sln
. If you use Visual Studio 2022, retarget project, and upgrade PlatformToolset tov143
before runningwindows_build.bat
Mac
Run
make
Run
make install
, libraries and bindings will be copied into a new created folder:install
Linux
Run
make
Run
make install
, libraries and bindings will be copied into a new created folder:install
Android
Install Android NDK (e.g. 21.4.7075529) via Android Studio
Run make for one of the following Android targets on macOS or Linux
Run
make install
, libraries and bindings will be copied into a new created folder:install
IOS
Run
make aarch64-apple-ios
Run
make install
, libraries and bindings will be copied into a new created folder:install
Examples
All Examples could be found here
Wallet related functions
function new_wallet
- Generates the HD wallet with a BIP39 backup phrase (English words) and password
function restore_wallet
- Recovers/imports HD wallet from a BIP39 backup phrase (English words) and password
function new_privatekey
- Generates a random private key
function new_privatekey_from_bytes
- Constructs private key from hex bytes
function new_privatekey_from_hex
- Constructs private key from hex string
ERC20, ERC721, ERC1155 related functions
function balance_of
- Returns the decimal amount of tokens owned by account_address.
Example
function name
-Returns the name of the token.
Example
function symbol
- Returns the symbol of the token.
Example
function decimals
- Returns the number of decimals the token uses.
Example
function balance_of
- Returns the number of tokens in owner's account_address.
function owner_of
- Returns the owner of the token_id token.
function name
- Get the descriptive name for a collection of NFTs in this contract.
function symbol
- Get the abbreviated name for NFTs in this contract.
function token_uri
- Get the distinct Uniform Resource Identifier (URI) for a given asset.
function transfer_from
- Transfers token_id token from from_address to to_address.
function safe_transfer_from
- Safely transfers token_id
token from from_address
to to_address
.
function safe_transfer_from_with_data
- Safely transfers token_id token from from_address to to_address with additional_data.
function balance_of
- Returns the amount of tokens of token_id
owned by account_address
.
function balance_of_batch
- Batched version of balance_of, get the balance of multiple account/token pairs
function uri
- Get the distinct Uniform Resource Identifier (URI) for a given asset.
function safe_transfer_from
- Transfers amount tokens of token_id
from from_address
to to_address
with additional_data
.
function safe_batch_transfer_from
- Batched version of safeTransferFrom
.
Last updated