Enervator Showcase

Technical Overview of Enervator

Below is a technical overview of Enervator.

*Enervator is described in more detail in Steve Huckle’s PhD Thesis. Some of the information here borrows excerpts from that work.

Enervator, which has a token symbol EOR, is an ERC777 token contract that inherits from OpenZeppelin’s implementation of ERC777. It aims to incentivise energy efficiency. Figure 1, below, shows that several other contracts support the token. They chiefly manage the supply and value of EOR and allow the exchange of sovereign currencies for the token.

Figure 1: Enervator class diagram

EnervatorManager is the default operator of Enervator. It holds the supply of EOR and sets the parameters that derive EOR’s value. EnervatorManager inherits from OpenZeppelin interfaces, IERC777Sender and IERC777Recipient, which provide definitions of hook functions that EnervatorManager implements. Those functions are called when EOR are sent or received. In particular, EnervatorManager implements the tokensToSend hook so that it calls a function from the Exchanger contract that updates the BuyDB contract with details of the tokens sent. As well as the BuyDB contract, the Exchanger contract maintains links to the Forex contract, which has functions that set and get the US Dollar exchange rates for sovereign currencies, and the DepositDB contract, which contains sovereign currency deposits. Those deposits govern the amount of EOR that can be bought.

Frontend Interfaces

Enervator is interfaced by two demos’ (please read ‘Loading Eneradmin and Enerchanger’, below, before trying to load the apps’ in your browser):

  1. Eneradmin
  2. Enerchanger

Eneradmin is responsible for managing Enervator. It mainly interacts with the EnervatorManager contract, described above. Figure 2, below, shows that it manages the supply of EOR, as well as setting the token’s value parameters and the sovereign currency US Dollar exchange rates. You do not (should not) have permissions to set any parameters with Eneradmin, but you can read both the token’s parameters and any exchange rates that have been set.

Figure 2: Eneradmin use case diagram

Enerchanger converts those exchange rates into their equivalent EOR value. It mainly interacts with the Exchanger contract, described above. Figure 3, below, shows that it is a proof of concept that simulates depositing cash and buying EOR. To use Enerchanger, first deposit some cash (imagine that’s a PayPal link or some such like), then use that deposit to buy some EOR.

enerchangerUseCaseDiagram

Figure 3: Enerchanger use case diagram

Both Eneradminand Enerchanger are web-based applications written in React. They employ a Redux state container that governs interactions with Ethereum via ethers.js, which uses web3.js as a provider, via the browser extension MetaMask. They also implement type-safety through Typescript. They are built and bundled using webpack.

Deployment

Enervator is deployed at address 0x5483b2996BBa07330E188Fe10BB101d4c1Ac8530 on Ethereum’s Rinkeby Test Network.

The webpack bundled apps Eneradmin and Enerchanger are deployed to dat, which is a peer-to-peer distributed data protocol. They are kept online via homebase, which is daemonised, via pm2, on a server with the dat tools installed.

An alternative to dat is ipfs. However, in this author’s opinion, dat is significantly easier to deploy and maintain than ipfs, not least because, with dat, you can copy new files to the same directory, and keep the same hash address. With ipfs, new files results in a new hash (although, I think there are ways to use DNS to circumvent that). Additionally, this author struggled to keep ipfs resources pinned and online, whereas homebase manages that seamlessly. Finally, dat appears much less corporate than ipfs.

*Disclaimer: this author hasn’t looked at ipfs for a while, so some of that described above may no longer be true.

Loading Eneradmin and Enerchanger

To load Eneradmin and Enerchanger in a web browser, you will need to be running Firefox with the Dat P2P Protocol and MetaMask extensions installed. MetaMask should be pointing at the Rinkeby Test Network, and you will need a few test Ether in your MetaMask wallet - you can get those from the Rinkeby Faucet.

Figure 4: The Enerchanger frontend interface

1 Like

Hi @glowkeeper,

Thanks for sharing.

What made you choose an ERC777 over an ERC20 token?

Simple - hooks. The tokenToSend hook means that my exchange contract can send EOR tokens and atomically update ny BuyDB contract with the amount of sovereign currency that was exchanged. That's really cool.

1 Like