Giter Club home page Giter Club logo

enjin-cpp-sdk's Introduction

Blockchain SDK by Enjin for C++

Build & Test Linux Build & Test Windows

Create blockchain video games and applications using the C++ programming language.

Learn more about the Enjin blockchain platform.

Sign up to Enjin Cloud: Goerli (Testnet), Mainnet (Production) or JumpNet.

Resources

Table of Contents

Compatibility

The Enjin C++ SDK is a C++17 library and is developed with cross-platform usage in mind. Platform and compiler combinations tested are as follows:

  • GCC 9.3.0 on Linux (64-bit)
  • Clang 10.0.0 on Linux (64-bit)
  • MSVC 2019 on Windows 10 (64-bit)

Installation

Conan

Recipes for this SDK are available on Conan Center for installation and package management.

Manual

The SDK may be built as a static or shared (dynamic) library. Use the ENJINSDK_BUILD_SHARED CMake argument to build as a shared library and set it to "on" (off by default).

The following dependencies are used for building the SDK:

The following libraries are used by the SDK for some of its functionality and must be locatable by CMake's find_package() function, however these libraries are not necessary to link to your own target to use this SDK:

To have the SDK build its default HTTP and websocket clients use the ENJINSDK_BUILD_DEFAULT_HTTP and ENJINSDK_BUILD_DEFAULT_WEBSOCKET as CMake arguments and set them to be "on" (off by default).

To utilize this SDK you may clone it into your project tree with:

$ git clone https://github.com/enjin/enjin-cpp-sdk.git

Then use the following in your project's CMakeLists file:

add_subdirectory(enjin-cpp-sdk)
target_link_libraries(my_target PRIVATE enjinsdk::enjinsdk)

Linux

Alternatively, on Linux you may include the SDK in your project by cloning and building it with the following commands:

$ git clone https://github.com/enjin/enjin-cpp-sdk.git
$ cmake ./enjin-cpp-sdk [options] && make -j -C ./enjin-cpp-sdk

From here, you may use CMake's find_package() function to find enjinsdk and link the library, enjinsdk::enjinsdk to your target.

Tests

For running unit tests in manual installations, Git (1.6.5+) is required to run CMake's ExternalProject_Add() function to acquire Googletest (1.10.0+) for the testing framework.

To have the test executable built, set the CMake argument ENJINSDK_BUILD_TESTS to ON and leave the BUILD_TESTING option from CTest enabled.

Quick Start

This example showcases how to quickly create and authenticate a client on the project schema which will then allow us to make further requests to the platform.

#include "enjinsdk/EnjinHosts.hpp"
#include "enjinsdk/ProjectClient.hpp"
#include <iostream>
#include <memory>

using namespace enjin::sdk;
using namespace enjin::sdk::graphql;
using namespace enjin::sdk::models;
using namespace enjin::sdk::project;

int main() {
    // Builds the project client to run on the Goerli test network.
    // See: https://goerli.cloud.enjin.io to sign up for the test network.
    std::unique_ptr<ProjectClient> client = ProjectClient::builder()
        .base_uri(EnjinHosts::Goerli)
        .build();

    // Creates the request to authenticate the client.
    // Replace the appropriate strings with the project's UUID and secret.
    AuthProject req = AuthProject()
        .set_uuid("<the-project's-uuid>")
        .set_secret("<the-project's-secret>");

    // Sends the request to the platform and gets the response.
    GraphqlResponse<AccessToken> res = client->auth_project(req).get();

    // Checks if the request was successful.
    if (!res.is_successful()) {
        std::cout << "AuthProject request failed" << std::endl;
        return 0;
    }

    // Authenticates the client with the access token in the response.
    client->auth(res.get_result().value().get_token().value());

    // Checks if the client was authenticated.
    if (client->is_authenticated()) {
        std::cout << "Client is now authenticated" << std::endl;
    } else {
        std::cout << "Client was not authenticated" << std::endl;
    }

    return 0;
}

Contributing

Contributions to the SDK are appreciated!

Issues

You can open issues for bugs and enhancement requests.

When reporting bugs, please state the OS, compiler, and CMake arguments used as well as reproducible examples if possible.

Pull Requests

If you make any changes or improvements to the SDK, which you believe are beneficial to others, consider making a pull request to merge your changes to be included in the next release.

Ensure that tests are passing when running the target enjinsdk_tests and add any necessary test classes or test cases for your code.

Be sure to include your name in the list of contributors.

Copyright and Licensing

The license summary below may be copied.

Copyright 2021 Enjin Pte. Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

enjin-cpp-sdk's People

Contributors

bishopjohnson avatar bradez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.