This project is not covered by Drupal’s security advisory policy.

The THX API and Web Wallet enables the embedding of blockchain features in any application. This module allows you to connect the THX API to your Drupal instance.
THX API uses the side-chain scaling solution Polygon and offers fast and cheap blockchain transactions. THX takes away the burden of paying transaction fees by relaying all contract state changing transactions to the API admin account.
Using THX API and the Rules module you can create both simple and advanced gamification rules for your Drupal project. For example; reward completing your profile information with points (= blockchain powered tokens) and allow people to spend these points to unlock premium content.

Configuring THX module

As can be seen in the composer file THX has dependencies of submodules real_aes, key and encrypt. Make sure to also get them if you download directly from Drupal. The easiest way to install the THX module is to do a composer require drupal/thx to get all dependencies.

Make sure also to create a thx.key so the module can encrypt the user data.
You can do this by running the following command

dd if=/dev/urandom bs=32 count=1 > /path/to/private-directory/thx.key

This information is also available in the README within the THX module.

After enabling you can configure the module on admin/config/thx/settings

Configuring THX

  1. Go to https://www.thx.network/ and register an account.
  2. Create an application and asset pool. This process is straightforward, but if needed information can be found on their website.
  3. Fill in the details on the Drupal side.

And that is all! You can check if the connection is working by clicking on the API health status. Just make sure to renew the access token first to be sure it’s valid.

Note that the module only provides a library of predefined methods that you can apply to your own code. Out of the box it will not do anything.

All the methods can be found in the service file within the THX module.

Example on how to use the THX library

Below we added an example where after new users sign up they get assigned to the asset pool and start receiving awards.

/**
* Implements hook_ENTITY_TYPE_insert().
*/
function your_module_user_insert(EntityInterface $entity) {
 // Get the THX config.
 $config = \Drupal::service('config.factory')
   ->getEditable('thx.settings');
 $asset_pool = $config->get('asset_pool');
 $mandatory = (bool) $config->get('blockchain_mandatory');
 
 // Only signup when the asset pool already exists.
 if ($mandatory === TRUE && !empty($asset_pool)) {
   /** @var \Drupal\thx\Service\ThxLibrary $thxLibrary */
   $thxLibrary = \Drupal::service(thx.thx_library');
   $thxLibrary->signup($entity->id());
 }
}

THX documentation

Questions and feedback

This module is under active development. We encourage you to post in the issue que or join the THX Slack to talk to the project’s team members.

Supporting organizations: 

Project information

Releases