Skip to content
JavaScript PHP Other
Branch: 8.x-1.x
Clone or download
Latest commit fe4f51f Apr 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Add Block explorer links to Network js settings. Sep 3, 2018
css Fix the network status indicator. Aug 23, 2018
doc-assets Add readme images. Apr 17, 2018
ethereum_signup Merge pull request #43 from jeffanthony/patch-7 Nov 27, 2018
ethereum_smartcontract fix minor typos Jan 15, 2019
ethereum_txsigner Match Drupal's configuration norm regarding casing Nov 25, 2018
ethereum_user_connector Add missing 'd' Jan 13, 2019
js Fix the Ethereum network selection page. Aug 16, 2018
misc/icons/bebebe Add a Ethereum network indicator in the toolbar. Aug 19, 2018
src Keep a separate field type that is network-independent. Sep 5, 2018
.eslintrc Cleanup. Aug 15, 2018
.gitignore Global transaction signer wrapping Metamask Mascara. Mar 27, 2018
ContractDevelopment.md Smart contract Admin UI. Mar 13, 2018
Readme.md Fix typo Nov 25, 2018
composer.json Update web3.js to 1.0.0-beta.35. Aug 16, 2018
ethereum.info.yml
ethereum.libraries.yml Merge branch 'add-ethereum-network-indicator' of https://github.com/a… Aug 22, 2018
ethereum.links.action.yml Add Networks and Servers as dependend config. Feb 26, 2018
ethereum.links.menu.yml Improve the Ethereum server selection page. Sep 2, 2018
ethereum.module Merge branch 'store-the-network-in-ethereum-address-field' of https:/… Sep 4, 2018
ethereum.routing.yml Improve the Ethereum server selection page. Sep 2, 2018
ethereum.services.yml Add a Ethereum Manager service and use it instead of static methods o… Sep 2, 2018

Readme.md

Drupal Ethereum

Introduction

Drupal Ethereum Module enhances the Drupal ecosystem with Ethereum SmartContract functionality.

The basic Ethereum module provides a basic framework to interact with the Blockchain via the Ethereum-PHP library and is prepared to talk to different Ethereum network nodes (like development, testing, live).

Ethereum Smartcontract submodule allows you to manage smart contracts and use Drupal configuration to connect to the contract depending on the Network the contract has been deployed to.

This module provides a schema to manage smart contracts (ethereum_smartcontract.schema.yml)

[Ethereum TXsigner](to be merged) module is responsible for the frontend part of user interaction. It is currently limited to Web3 enabled Browsers, like Metamask browser extension, Brave Browser, Mist browser, but also supports Metamask Mascara (but Mascara is early Alpha by now).

This module provides a web3 instance so you will have the same Web3 version and not depend what is injected by whichever browser/extension is used.

Ethereum User connector is a submodule providing a very simple registry contract (See the Proof of concept (POC) video. This is a early example how the actual applications would be Able to use the infrastructure provided by Drupal Ethereum module.

This module is an example of a Smartcontract. Currently refactoring to match the post POC infrastructure described above.

Community

You might watch my Drupal conference talks from Vienna or Baltimore.

Drupal Ethereum Getting started

TLDR; Quick set-up

  • Add Web3js to the "repositories" section of your root composer.json (see "Add the following to the repositories section..." below)
  • Run composer install to get all required dependencies
  • Make sure Drupal has a Ethereum Node to read from by configuring Configure Ethereum connection (/admin/config/ethereum/network). Saving the form settings will validate the current settings and let you know if something is wrong.
  • You can start testing with Infura networks provided.

If you used composer to install Drupal core and the Ethereum module everything should work out of the box using Infura's free service to connect to the Ethereum network.

Long version

The quickest way to do this is to follow the steps below. You will need PHP Composer and drush installed on your system. Alternatively, you can install Drupal manually.

Install Drupal

# Download latest Drupal
composer create-project drupal-composer/drupal-project:~8.0 drupal --stability dev --no-interaction

# Create a Database
mysql -uroot  --execute="CREATE DATABASE \`drupalEthereumTest.local\`;"

# Drupal with drush
# Create a configuration export directory. This is not required, but very usefull.
mkdir drupal/config

# Change to web root 
cd drupal/web/
# Scripted drupal installation. Revalidate the database. It will be overwritten.
drush site-install standard --db-url="mysql://root:root@localhost:3306/drupalEthereumTest.local" --account-name="tho" --account-pass="password" --site-name="drupalEthereum.local" --account-mail="email@donkeymedia.eu" --site-mail="email@donkeymedia.eu" --config-dir="../config" --notify="global"

DON'T FORGET TO CHANGE YOUR PASSWORD AFTER FIRST LOGIN.

Composer install

RestUI is a user interface for Drupal 8's REST module. You'll need it for development.

Add the following to the "repositories" section of your root composer.json file:

{
    "type": "package",
    "package": {
        "name": "ethereum/web3.js",
        "version": "1.0.0-beta.35",
        "type": "drupal-library",
        "dist": {
            "url": "https://github.com/ethereum/web3.js/archive/v1.0.0-beta.35.zip",
            "type": "zip"
        }
    }
},

Composer commands need to be run from the drupal directory

# Download using composer
composer require drupal/ethereum drupal/restui drupal/admin_toolbar 
composer install 
 
# Enable the modules
cd web/
drush en ethereum restui admin_toolbar_tools -y

Visit /admin/config/ethereum/network, save the configuration settings then check the status page at /admin/reports/ethereum to verify that it's working.

Networks & Ethereum nodes

Networks are Drupal configuration. This module provides a List of networks (ethereum.ethereum_networks.yml). Ethereum nodes and Networks are matched by the Ethereum network ID. Currently there is no UI for editing networks. You can add new network IDs by changing file above and re-enabling the module.

Network Settings are provided at /admin/config/ethereum/network.

Ethereum Server also refered as Ethereum Nodes are the connection to the Ethereum Blockchain. We manage the Servers as editable configuration entities.

Default Network setting allows to select a default route Drupal will use to connect to Ethereum Blockchain.

Running your own Ethereum node

Ganache is a very easy to use Ethereum Blockchain for development and testing. It is available for many platforms and has a Block explorer build in.

Docker Ganache-cli has no Block explorer, but it allows you to keep a persisten test chain. Have a look at ganache-cli-docker-compose.

Geth is the go-ethereum client. If you want to use geth (go-ethereum client), install it then start the geth server with rpc. On a Mac this looks like this (be aware that the "*" allows connections from any host):

 geth --testnet  --rpc --rpccorsdomain="*"

Development environment with Truffle

If you want to experiment with developing your own smart contract, it is recommended to use Truffle.

Check out the currently provided Login Smart Contract by cloning/forking it. The repository contains a very basic App which helps you understand the registration contract from ethereum_user_connector module.

You can now import SmartContracts from Truffle directly into Drupal configuration.

You can’t perform that action at this time.