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.
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.
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 protected]" --site-mail="[email protected]" --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 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.
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="*"
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.