Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Blockchain networks to support test and production environments
Energy Web supports two distinct blockchain networks:
The Volta Test Network (Testnet)
The Energy Web Production Network (Mainnet)
These networks are independent of each other. They each have their own chain specifications that the OpenEthereum client uses to configure the blockchain. You can view them on github here.
You cannot transfer tokens between these two blockchains. They each use their own unique utility token that pays for transaction fees on the blockchain (read more about this here).
The Energy Web Chain's main network utility token is the Energy Web Token, which has real fiat value. The Volta Test Network's token is the Volta Token, and it has no real value. They are not interchangeable - if you have Volta tokens, this does not mean you have Energy Web Tokens, and vice versa.
Volta is the pre-production test network (testnet) of the Energy Web Chain. It’s the blockchain equivalent of a test server or test environment in traditional software development. Most blockchains have at least one test network. Ethereum, for example, has several test networks for pre-deployment testing.
Volta is used as a staging network to:
Test smart contracts before they are deployed on the production chain. If you write your own smart contract, you will want to deploy it and test it on Volta first to make sure it works as expected. Because tokens on the testnet (Volta tokens) have no real value, you can test thoroughly and incur no cost.
Test protocol updates before they are deployed on the production chain. Each time there is an upgrade to Ethereum's protocol, we test it on the Volta Network first.
The utility token for the Volta Test Network is the Volta token. Volta tokens have no real value, but you will need them to "pay" for transaction costs associated with interacting with smart contracts on the Volta network. Read more about the Volta Token and how to get some here.
Connect to Volta Test Network using MetaMask - you will need to connect to the Volta network in order to access applications and smart contracts deployed on Volta
Run a local node - you have the option to run your own local node of the Volta network. You can read about the purpose and benefits of running a local node here.
The Energy Web main network (mainnet) is the production network of the Energy Web Chain. The gas fees to pay for transactions require Energy Web Tokens (EWT), which have real value. You can read more about EWT and how to acquire it here.
You can read more about transaction costs on the Energy Web Chain here.
Connect to Energy Web Main Network using MetaMask - you will need to connect to the Energy Web Chain in order to access applications and smart contracts deployed on the Energy Web main network
Run a local node - you have the option to run your own local node of the Energy Web Chain. You can read about the purpose and benefits of running a local node here.
In order to deploy a smart contract to the Energy Web Chain Main Network, rather than the Volta Test Network, the steps are identical, except that you will connect your MetaMask to the Energy Web Chain rather than to Volta. We recommend that you always deploy and test your smart contracts to Volta first to make sure they behave as expected.
In the "Environment" dropdown, selected "Injected Web3". Notice that when you select this, "Custom (73799) network shows up. 73799 is the Volta Test Network - this confirms that we are connected to the Volta network via MetaMask.
You will need to confirm the connection to MetaMask.
Go to the file explorer panel (select the first icon on the left panel). Add a new .sol file in the 'Contracts' folder. Below it is called VoltaContract.sol.
In the .sol file, add the following code:
If there are no errors, click "Compile VoltaContract.sol" (make sure that the 'Language' selected is 'Solidity').
If you want to interact with your contract in the future using an API client, you will need the contract's ABI. The ABI is in the bottom right hand corner of the Solidity Compiler page after it is compiled.
Click 'Deploy' to deploy the contract to Volta Test Network.
Confirm the transaction in MetaMask. Make sure that you have some gwei as a gas price by doing the following:
Select EDIT
Select "Edit suggested gas fee"
Make sure you have a Gas price of 6e-8 GWEI (this should be autofilled)
Confirm the transaction in MetaMask
Once your contract is deployed, you can see it in the "Deployed Contracts" section of the same page ("Deploy and Run Transactions")
Click on "get" to test our contract's functionality. Remember from the code that is should just return a string "Volta".
Copy the address of the contract by clicking the copy icon.
Paste the contract address in the search bar at the top right:
Nethermind Client
Full specification for Nethermind configuration options can be found here:
Run the following command in your terminal -
Your local node should start:
This section describes minimal setup to run an RPC node locally or on the server using Docker container run with docker-compose. This is solely for development purposes, it's not a production grade recommendation.
Verify that prerequisites are installed:
Create working directory
Create docker-compose.yaml file
Start container:
Examine logs:
The log output should be similar to the following
Run a full instance of the blockchain on your machine
You have the option of running a full node of the Energy Web Chain main network or Volta test network locally. Running a local node does requires a degree of technical capability. It helps to understand the benefits of doing so, and the alternatives to running a full local node.
A node is any machine that is actively running client software and is connected to the blockchain. Blockchain is often called a “peer-to-peer” network, because its network is made up of many peers running nodes simultaneously that are connected to each other.
Depending on the blockchain you are you connecting to, this can take up large amounts of space and take a long time to retrieve and sync the history of the chain on your machine. For example, synching with the Energy Web chain will require much less resources than syncing with the Ethereum mainnet, as it is a much larger and longer-running blockchain.
The more nodes there are, the more secure the system is as a whole. Blockchains are decentralized technology, so by design the system performs better if there are multiple instances of it rather than just one. The more nodes there are, the less points of failure or opportunities for malicious action.
Running a local node is not necessary to use applications that run on the blockchain or transfer tokens.
Multi-core CPU
4GB RAM
SSD drive and free space
EWC RPC node - 150 GB
Volta RPC node - 200 GB
A decent DSL connection is required
Download and save the chain config to your local machine.
Volta Testnet chainspec:
Energy Web Chain (production) chainspec:
Run the following command in your terminal. Provide the path to the chain config that you want to use. The following command references the Volta chain config.
Your local node should start:
Get the URL of your MetaMask account. You can do this by clicking the settings dropdown and selecting "Expand View."
When the view is expanded, copy the URL in the browser
Run the following command in your terminal
This section describes minimal setup to run an RPC node locally or on the server using Docker container run with docker-compose. This is solely for development purposes, it's not a production grade recommendation.
Verify that prerequisites are installed:
2. Create working directory
3. Create docker-compose.yaml file
4. Download database snapshot - this takes some time and requires resources due to the size of the .tar file, but it will speed up synchronization process.
*Note that this step is optional. If you do not download the database snapshot, move to Step 6.
Volta (depending on your internet connection ~1 hour download time for us):
Energy Web Chain (production) (30 minutes download time for us):
5. Unpack database snapshot. This snapshot only works with OpenEthereum client.
*Note that this step is optional. If you did not complete Step 5, skip this step and move to Step 6.
Volta:
Energy Web Chain (production):
6. Set permissions:
8. Start container:
9. Examine logs:
The log output should be similar to the following (sometimes the logging output does not appear immediately, wait some time):
10. After some, you will sync with the network. Until a full sync, you will see be in a "syncing" state:
The output will show current synchronization status:
It will take some time to fully sync with the current state of the blockchain. When the synchronization is finished status will be:
You will need to (or another Ethereum wallet) to connect to EW-DOS applications on the Volta test network or the main network, and to sign transactions on the blockchain.
Read more about using MetaMask .
If you are using applications or smart contracts on the , you will need .
Learn how to get Volta Tokens .
Once you have Volta tokens, you will need to .
If you are using or developing applications or smart contracts deployed on the , you will need to have .
Learn how to get EWT .
Once you have EWT, you will need to .
Below are steps to deploy a on the (the test network for the ) using . Remix is a web application used to compile, deploy and test smart contracts on Ethereum networks.
Once your smart contract is deployed, you can use the contract's ABI and address on the blockchain to interact with its public methods. For more information on how to interact with smart contracts, go .
You can see steps for doing this are . If you do not have a MetaMask installed, you can do so .
You will need to to pay for the transaction fee for deploying the smart contract to the blockchain. For directions on how to get Volta Tokens, go . To learn more about what transaction fees are, you can go .
*Note that if you are deploying to the Energy Web Main Network, you will need to have .
Go to the . If you are deploying to the main network, the block explorer is .
You can see the smart contract address details, the block it was created in, and the byte code. The block explorer contract details from the example above is .
Now that you have your smart contract's address on the blockchain and its ABI, you can use an Ethereum API client to interact with your contract in your decentralized applications. For a tutorial on how to do this, go .
See Nethermind documentation for Docker:
There are a number of benefits to running your own node, which are .
A 'client' is software that implements a blockchain's protocols and allows you to connect directly with the blockchain - that is to read data from the blockchain or initiate transactions on the blockchain, such as transferring tokens. Anyone can create client software, as long as it implements that blockchain's official protocols. Ethereum's protocols are specified in their , and there are a number of Ethereum clients to choose from.
Depending on if you are running a full node, a light node, or an archive node (see the differences between these nodes ), your client will sync with the current state of blockchain and then continue to execute every transaction that is added to the blockchain. Essentially it is having a live copy or version of the blockchain running locally on your machine.
To run a node, you need to install the client software. The Energy Web mainnet and Volta testnet both use the client (formally known as Parity), because it supports the , which is a consensus algorithm specifically for Proof-of-Authority (PoA) blockchains. You can read more about the PoA consensus algorithm and why we implemented it for the Energy Web Chain .
Only can create or 'seal' new blocks on the Energy Web Chain. If you run a full local node, you will be able to validate transactions, but not create new blocks.
Your transactions are more direct and more secure. Software that provides intermediary connections to the blockchain like or are, like any other web-based software, susceptible to downtime or error. By connecting to the blockchain yourself, you are removing your dependency on external providers for secure and direct connection. You also do not expose your public keys to the browser.
You can self-verify transactions. You have part or all of the blockchain running on your node, so you can query the chain for transactions directly (and as often as you want) rather than relying on a user interface like a . Your queries can be more specific and efficient, giving you only the information that you need, for example, ‘how many transactions did addresses X, Y and Z send during this time period on each day for the last 30 days?’
You are not subject to rate limits. Infura (and therefore MetaMask, as it implements Infura to connect to the blockchain) . If your development requires a lot of requests to the blockchain, running a local node may be more efficient.
To use applications deployed on the Energy Web Chain, or to transfer tokens, you can connect to the blockchain through using a remote RPC. You can see guidance for doing that on the Volta Test Network and the Energy Web Main Network .
You need to meet OpenEthereum hardware requirements and have enough disk space to store database snapshots (which will grow in time).
Note that there are different chainspec files for the and the :
The chainspec file for Volta Test Network is .
The chainspec file for Energy Web Main Network is .
1. Download the chainspec file.
Download
Full specification for OpenEthereum configuration options can be found here:
Connect your MetaMask to the Volta Test Network or Energy Web Chain via remote RPC. You can read how to do this
See OpenEthereum documentation for Docker:
11. Check the database synchronization status in the command line using OpenEthereum's 'eth-syncing' module:
Incorporate external data sources into your smart contracts
By themselves, smart contracts cannot access data outside of the blockchain or send its data to services outside of the blockchain. To do this, smart contracts use middleware called an oracles, which are third-party services that fetch and send data to and from smart contracts. Oracles are similar to traditional web-based API services.
Smart contracts can contain logic that triggers certain changes or actions based on external data from an Oracle. Without oracles, blockchains and their applications that cater to specific industries that rely on real-time changes such as finance, commodity trading, or IoT, would not have access to the data necessary to react to real-time external factors.
It's important to keep in mind that oracles are agnostic of the data they transmit - they are only responsible for fetching, verifying and relaying the data to and from the blockchain.
Inbound oracles send data to the blockchain. This is the most common type of oracle. Like traditional API services, the inbound data that the oracle provides can be anything that your smart contract needs for internal logic that it cannot access from the blockchain or the smart contract itself.
For example, you want to send 10 EWT to a friend's address when the price of a specific stock goes above $10 per share. An oracle will provide you with the data about stock price, and the blockchain logic will trigger the send when the oracle delivers data indicating that the price of a stock goes above $10.
Outbound oracles send data about events that happen on the blockchain to third party applications. For example, an account could receive a payment and trigger an outbound oracle to a mechanism that activates a pv solar panel.
Oracles can gather data from software and hardware. A software oracle interacts with and fetches data available from any web source that exposes its data. Some common examples are weather APIs, real-time stock information and exchange rates.
Hardware oracles interact with 'physical' data sources like sensors from IoT devices, QR codes or bar codes. Some examples could be reading the temperature from a smart thermostat or fetching data from a flood sensor..
Centralized oracles are developed, maintained and controlled by a single entity. One oracle is responsible for fetching data from one or many data sources, and then transmitting that data to the smart contract on the blockchain. You could liken this to using a centralized database for your smart contract's external data sources.
Decentralized oracles aggregate data from multiple sources using multiple oracle nodes, so that there is no single point of failure for data retrieval, and no single point of failure for the oracle itself. Decentralized oracles are more aligned with the wider community of public blockchain.
Regardless of the data source, or if it is centralized or decentralized, all oracles provide three main functionalities:
Listen to the blockchain network for incoming requests for off-chain data
Fetch data from the requested off-chain source
Transfer the data to the blockchain via a signed transaction
Insert the data into a smart contract’s local storage. Once the data is in the smart contract's storage, it can be used to trigger logic within that smart contract, or it can be available for other smart contract's to use
Depending on the nature of the data itself and how the smart contract uses the data, oracles can be designed to communicate with smart contracts using three main patterns:
Publish-subscribe: An oracle broadcasts data, and certain smart contracts are polling or "listening to" that oracle for changes in data. An example: "Poll the temperature of region X every 10 minutes. If the temperature is above 70 degrees celsius, turn the smart thermostat to 'on'."
Immediate-read: Oracles hold data in their storage and provide this data on request. Users or devices query the oracle for this data at the same time that it is needed. An example: "Is device X in a list of authorized devices to provide solar power to region Y."
Request-response: External accounts (via decentralized applications) interact with a smart contract and necessitate data from the oracle. The smart contract sends the data parameters to the oracle and performs the third-party data query. When the data is fetched, it sends the result back to the smart contract for the decentralized application to use. Because the decentralized application cannot always wait for the data, this occurs asynchronously. An example: A user selects from a dropdown on a decentralized application a date range to determine the average temperature of each day during the range. The start and end date are sent to the data oracle to fetch the temperatures for the days in the given date range. The data is sent back to the smart contract to perform necessary logic based on the data.
Chainlink provides decentralized oracle networks. This tutorial covers:
Setting up a Chainlink node and using it from a smart contract on the Volta test network
Aggregating data from multiple Oracles, and how to use the public EWT/EUR Price Pair Oracle infrastructure on Volta
Design principles of Chainlink oracles
Scenarios where it makes sense to use Chainlink
Using smart contracts on the Ethereum Virtual Machine
EW-DOS utility layer packages and SDKs interact with smart contracts that are deployed on the Energy Web Chain. To do this, they use API Client Libraries to connect to the blockchain and create instances of smart contracts to access their public functions.
If you're not familiar with what a smart contract is, you can read Ethereum's introduction to smart contracts here.
Below we provide an overview of API Client libraries and a some code examples. Note that exact implementation varies in each package or SDK, but the fundamental concepts remain the same.
You can interact with smart contracts (i.e. call their public read and write functions) on the the Energy Web Chain and the Volta Test Network using any Ethereum API client library. Client libraries allow you to connect to and interact with the blockchain network. You can read about all the functionalities of Ethereum API client libraries in the Ethereum documentation here.
The most popular JavaScript libraries for interacting with Ethereum networks are ethers.js and web3.js. EW-DOS uses ethers.js, so below we will provide ethers.js examples, however concepts will be similar among different client libraries.
When interacting with a contract, you use a library to first create a Provider, which is a connection the blockchain. You then use the provider to create an instance of the smart contract that you want to interact with. Once this instance is created, you can call the public methods that are exposed in the smart contract.
A provider is a connection to the blockchain. It gives you an interface to interact with the network. To create a JSONRpcProvider, you will need the JSON RPC Url. To create an IPCProvider, you will need the path local IPC filename (this is only available in node.js).
You can see the full ethers.js documentation on Providers here.
See source code here
To create a new instance of a contract that is already deployed on the blockchain, you need three pieces of information:
The contract's ABI- the ABI (Application Binary Interface). The ABI is a JSON object that provides the interface to your smart contract. It defines the contract's constructor, events and the behavior of its public functions. The contract's ABI is generated with the smart contract is compiled.
The contract's address - every smart contract has an address when it is deployed to the blockchain. You can deploy the same contract on multiple blockchains, but each contract will have a different address.
The provider
You can see the ethers.js documentation **** for creating a new instance of a deployed Contract here.
See source code here
The Contract method returns a new instance of that contract at the address passed in. Now that we have an instance of this contract, we can interact with its public methods:
See source code here
Smart Contracts
Link to Source Code
IAM Smart Contracts
For a tutorial on how to deploy a smart contract on the Volta Test Network or Energy Web Main Network, go here.
In this section, we'll walk through how to connect to the Energy Web blockchain, and the Volta testnet using the MetaMask browser extension.
Prerequisite: Metamask plugin is installed in the browser; this section explains how to add the Energy Web blockchain to it.
To configure Metamask to connect to the Energy Web blockchain or to Volta, the fastest way to do that is using the Energy Web MetaMask configuration toolbox or Chainlist
Depending on what network you connected to, and if you have Energy Web tokens or Volta Tokens in your account, you should see your balance.
The Ethereum Name Service is available on Energy Web Chain and Volta Testnet
The Energy Web blockchain uses the Ethereum Name Service (ENS) for name-spacing assets that are anchored on our blockchain. ENS is a critical part of providing user-friendly dApps. You can interact with the ENS contracts that are deployed on the Energy Web Chain in several ways.
Below we explain:
The Ethereum Name Service (ENS) is a distributed, open, and extensible naming system based on the Ethereum blockchain.
Machine-readable blockchain identifiers such as Ethereum addresses, content hashes and metadata are difficult to interact with in a user interface. ENS was developed to provide human-readable, user-friendly mapping for these identifiers, and to give users the ability to reserve domain names for our applications. To date, it is the most widely used blockchain naming standard.
ENS solves a similar problem that Domain Name Systems (DNS) provide. DNS lets us navigate to a website using human language and an intuitive format (www.energyweb.org), rather than using an IP address that is impractical to remember and has no association with the content that it directs you to (104.26.13.227). Similar to DNS, ENS supports a structure of dot notation for hierarchy and nesting.
Using ENS, you can create identifiers for the following blockchain content types:
Address
Reverse address (e.g. an address resolves to alice.eth)
Content hash (e.g.: IPFS/Swarm hashes)
ABI definitions
DNS records
Public keys
Smart contract interfaces (see EIP 165)
Text (email, physical address, geo location, metadata)
You can see a full list here in the ENS documentation, as well as the specifications for resolving each type.
As a simple example, if you want to send funds to your friend Alice, you can specify the recipient as “alice.eth” instead of “0x0052569B2d787bB89d711e4aFB56F9C1E420a2a6”.
If you want to refer to a content hash of a report listed at your custom domain, you can refer to it has “myReport.myDomain”, instead of by the hash identifier.
The two main components of ENS, explained below, are responsible for storing the human-readable address in smart contract registry, and resolving it to its original content.
ENS has two primary components: the Registry and the Resolvers.
A smart contract that holds all of the domains/subdomains, the owner of the domain, and the domain resolver (the method used to map it back to its original address.) You can see the ENS Registry smart contract here.
Methods that translate the human-readable names to their original address. A resolver has multiple methods, each of which are responsible for resolving different types identifiers (for example, one method is responsible for resolving contract ABI definitions , one method is responsible for resolving content hashes.)
You can see the ENS smart contracts for all of the resolver types here
You can read more about the Registry and Resolvers in the original documentation here
What’s important to take away is that the two primary components for ENS are smart contracts that hold a mapping for all domains/subdomains, and provide resolver methods for translating different address types to a human readable form. These contracts are extendible, so you can add your own resolvers for different address types.
Energy Web has deployed the ENS smart contracts on the Energy Web mainnet and Volta testnet. You have several options for interacting with ENS, depending on your use case.
Contract
Source
Volta address
EWC address
Registry
0xd7CeF70Ba7efc2035256d828d5287e2D285CD1ac
0x0A6d64413c07E10E890220BBE1c49170080C6Ca0
ETH Registrar Controller
0xb842CCA1682DC2Ee6A9da6A59bA4B5C736b229cD
0x9C99a28D3d702E6096361Ff31E724b772B5D709e
ETH Base Registrar
0x5630EBDbf41624fF77DcBfC4518c867D93E42E9f
0x3BDA3EE55a5b43493BA05468d0AE5A5fF916252f
Public Resolver
0x0a97e07c4Df22e2e31872F20C5BE191D5EFc4680
0xA517983Bd4Af4DF0Ed9b52DA4BC405d0A95eE7E2
Reverse Registrar
0xff7Befa016689dC5D89165867a65CF26B73e6514
0xcB9BCAa8010F51D6484570B99B127e8a26B6B468
Reverse Resolver
0x775e2a91501cdadeA65BF8eBb94a82529Fc2C34B
0x0C12c9087342DafE42b28A93998CEd711DC9a614
You can use this interface to search for available names in the Energy Web domain and register them to your address. Note that you will need to have sufficient funds in your wallet to do so as there is a fee for name registration.
Our management app is forked from the Ethereum Name Service Manager app.
There are a number of libraries that support ENS. These libraries have methods to configure your registry, and manage and resolve names. The IAM client library and IAM Cache server both connect to ENS using the ethers library. You can see the Ethers API support for ENS here.
For a full list of libraries that support ENS, see the ENS documentation here.
Smart Contracts
System Contracts
Energy Web
Contracts
is a browser extension and a mobile app that handles blockchain account management and helps users securely interact with a . It’s supported in Chrome, Brave, and Safari browsers, as well as it is available for Android and iOS devices. By default, you can connect to the Ethereum Mainnet or any of the Ethereum test network.
If you don’t have MetaMask installed install the extension first. Learn about here.
1. Click on the "Networks" dropdown at the top of your MetaMask interface and select "Custom RPC"
2. Add the new network using the following settings
Field
Value
Network Name
EWC
New RPC URL
https://rpc.energyweb.org
Chain ID
246
Currency Symbol
EWT
Block Explorer URL
http://explorer.energyweb.org
3. Save the settings and switch to the newly added network 'EWC'
1. Click on the "Networks" dropdown at the top of your MetaMask interface and select "Custom RPC" 2. Add the new network using the following settings
Field
Value
Network Name
Volta
New RPC URL
https://volta-rpc.energyweb.org
Chain ID
73799
Currency Symbol
VT
Block Explorer URL
http://volta-explorer.energyweb.org
3. Save the settings and switch to the newly added network 'Volta'
The Consortia RPC is an alternative to using the Energy Web Mainnet RPC.
1. Click on the "Networks" dropdown at the top of your MetaMask interface and select "Custom RPC"
2. Add the new network using the following settings
Network Name
EnergyWeb RPC
New RPC URL
http://consortia-rpc.energyweb.org
Chain ID
246
Currency Symbol
EWT
Block Explorer URL
https://explorer.energyweb.org