Enter details in Registry

It is necessary to enter our details into the decentralized Open Charging Network Registry. This will allow other parties to find and route messages to us. The OCN Node will not accept a credentials connection request without an appropriate registry listing, so let’s do that now.

 

2.1 Finding the node’s information

We wish to know the public information about the OCN Node that we want to use so that we can enter these details into the registry. We can make a simple GET request to the node at https://qa-client.emobilify.com/ocn/registry/client-info to find out its public URL and Ethereum-compliant address, which is used to identify the node on the network.

You can skip this if you like, as we already have the information here:

If you want to use the second public OCN Node (run by Elaad NL) on the Public Test Environment, you can make a GET request to https://ocnnode.elaad.io/ocn/registry/client-info to find the required information.

 

2.2 Funding a wallet

As a a final preparation step, we need to create and fund our Ethereum wallet. This will be used to enter our data into the registry and forms a part of our identity on the network, along with the OCPI country code and party ID of our service.

There are various tools to create a wallet. As we don’t need all the features of a wallet right now, we can go ahead and generate a keypair using, for example, Vanity-ETH. Leave the default fields as they are and click generate, being sure to save the resultant private key (having clicked to display it).

Next, take the generated address and visit the Volta faucet. Enter the address there and request 1 Volta Ether, which will be more than enough to pay for the transaction to add our details to the registry.

 

2.3 Sending the transaction to the registry

There are various ways to interact with Ethereum smart contracts, but here we have provided contract wrappers to hopefully make the process simpler. The following information is also available in the OCN Registry repository.

In this case we will use the JavaScript wrapper, however there is also a Java wrapper if you prefer. Note that the Java wrapper requires additional setup (such as knowing where the Registry contract is located and which RPC node to connect to):

  • Network: Volta

  • Registry contract address: 0x50ba770224D92424D72d382F5F367E4d1DBeB4b2

 

You can instantiate the wrapper with the network (in this case “volta”) and the private key we generated above.

const SnC = require("./src/main") const snc = new SnC("volta", "0x123...89a")

 

Next, prepare the data that will be entered into the Registry:

const countryCode = "{{COUNTRY_CODE}}" const partyID = "{{PARTY_ID}}" const nodeURL = "https://qa-client.emobilify.com/" const nodeAddress = "0x295dfa0b50aebc499383cd1c1272a485e66e81f3"

 

We want to sign this data first, so that future consumers will be able to verify its integrity. The data will be signed with the private key that you generated.

const signature = await snc.getSignedRegisterOrUpdate( countryCode, partyID, nodeURL, nodeAddress )

 

Finally, we will send the transaction to the Volta network. This will take about 5 seconds to complete.

 

The resultant transaction hash can be looked up on the Volta block explorer to ensure that it was successful.