What is Share&Charge?
Share&Charge is a Sharing Platform for both private and public electric vehicle charging stations. While you may find a lot of information about the concept behind Share&Charge at https://shareandcharge.com, this article focuses on technical side of the project, and is aimed at an audience of developers.
How does it work?
Share&Charge uses the public Ethereum blockchain as a transaction layer. The following are the three main smart contracts deployed:
- LibManager (0xf4d9d65481352C3Afd0750B46FbE0462eb29206d)
This contract holds references to all the other contracts. This allows us to arbitrarily update the contracts in order to implement new features or fix bugs. Note that the addresses of the contract(s) may change in the future, but can and will always be found in LibManager. - MobilityToken (0x8262a2a5c61A45Aa074cbeeDE42c808D15ea3ceD)
A ERC20-Token contract that holds the balances and also enforces the regulatory frameworks. - ChargingPoles (0x61c810e21659032084A4448D8D2F498789f81CB5)
This contract is a registry of all charging poles. It on-boards the logic to handle start/stop operation at the stations.
Where are the ABIs?
We have now reached the milestone where we can make the ABIs available! We know some of you are keen to interact with the contracts directly. These are the ABIs (Application Binary Interfaces) which you’ll need in order to interact with these three contracts:
The sources for the smart contract have not been made public yet as they are still ongoing security audits, even though they do not hold any ETH. Once these are completed, we are looking forward to publishing the contracts’ sources on github to welcome your feedback and ideas. Note that we are also planning a bug bounty program.
How do I send a transaction to the contracts?
While experienced developers already know how to use the ABI and send transactions, there many different ways to accomplish this, including:
- Mist Browser
The Ethereum Foundation dapp-Browser - Parity UI
The Parity Client built-in web3 Interface - MyEtherWallet (MEW)
An online wallet, which enables you to send transactions without having to run a software client
No matter what option you selected, you will need to follow these steps:
- Install and start a client of your choice and sync the public Ethereum chain (unless you are using MEW, of course).
- Import your private key. The private key to your account was sent to you after confirming your email during the Share&Charge signup phase. Add this key to your client’s /keystore folder or import the UTC file. The password for this keyfile is the one you chose when registering.
- Add the contract(s). Start watching the contracts by using the addresses and ABI as described above.
- You are now ready to send transactions!
How do I get Tokens?
In order to pay for charging you need to get Mobility Tokens. Each token is backed up with a real Euro and fully regulated through German laws!
You can purchase a few of these tokens through the Share&Charge app:
- Register your email address.
- Confirm your email address. After confirming your address, you will receive a email containing your randomly generated private key, encrypted with your password.
- Save this private key in your /keystore folder
- Complete your profile in the app (this is the KYC step)
- Go to wallet section and purchase Euro Tokens using paypal, a credit card or SOFORT.
How do I manually start a charging-transaction in the blockchain?
Before you can send a transaction to the start function of the ChargingPoleContract, you’ll need to make sure you have an Ethereum address whitelisted in the TokenContract. This is done as soon as you have registered and confirmed your email through the application. You can check whether or not you are whitelisted by calling getWhitelist(address _user)
In case it is not a free charging station, you will also need to get some tokens.
If you want to find out the price of charging station, you may call the constant function:
ChargingPoles.costTimebased(bytes32 poleID, address user, uint32 wattPower, uint32 secondsToRent)
poleID
: the ID of the charging station you wish to startuser
: your public addresswattPower
: the maximum charging power of your car in W/hsecondsToRent
: the time in seconds you plan to charge. You may stop earlier, but after this time period has expired anyone would be allowed to stop the charging process unilaterally
to start charging :
ChargingPoles.start(bytes32 poleID, uint32 wattPower, uint32 secondsToRent)
poleID
: the ID of the charging station you wish to startwattPower
: the max. charging power of your car in W/hsecondsToRent
: the time in seconds you plan to charge. You may stop earlier, but after this time period has expired anyone would be allowed to stop the charging process unilaterally
to stop :
ChargingPoles.stop(bytes32 poleID, uint32 watt)
poleID
: the ID of the charging station you want to stopwatt
: the measured watt. In most cases this is zero, because it is only accepted in the case of a kwh-based tariff at an authorized, metered provider
Code Samples
In case you want to run code without UI, you can also install geth and import the downloaded private key :
mv Download/UTC-<MYKEY> ~/.ethereum/keystore # start geth with console and # then adjust and paste code from charging_example.js geth console
Then adjust this code according to your preferences and run it within the console:
Article originally written by
Simon Jentzsch,
Founder and CTO of Slock.it
Twitter: @simon_jentzsch
Contact: [email protected]
and edited by
Stephan Tual
Founder and COO of Slock.it
Twitter: @stephantual
Contact: [email protected]