masaun / streaming-electricity-marketplace

This is a smart contract that allow a buyer to be able to buy electricity⚡️ with subscription (streaming) plan.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Streaming Electricity Marketplace


【Introduction of the Streaming Electricity Marketplace】

  • This is a smart contract that allow a buyer to be able to buy electricity with subscription (streaming) plan.
  • Libraries and smart contracts of below are used for implementing this smart contract.
    • Streamr (for subscription)
    • Provable Things (for oracle of electricity price)

 


【Workflow】

  • ① A producer create the electricity as a product.
    At that time,
    • a product ID for the electricity is published.
    • Subscription fees and subscription period are defined by a producer.
  • ② A buyer buy the electricity as a product which they prefer by paying for subscription fees.
  • ③ Once subscription period is expired, a buyer can extend subscription period by paying for subscription fees again.

 


【Remarks】

  • Version for following the Streamer smart contract
    • Solidity (Solc): v0.5.16
    • Truffle: v5.1.60
    • web3.js: v1.2.9
    • openzeppelin-solidity: v2.5.0
    • ganache-cli: v6.9.1 (ganache-core: 2.10.2)

 


【Setup】

① Install modules

  • Install npm modules in the root directory
$ npm install

  • Install npm modules in the ./ethereum-bridge directory
$ cd ethereum-bridge
$ npm install

② Compile & migrate contracts (on local)

$ npm run migrate:local

③ Test (Mainnet-fork approach)

  • 1: Start ganache-cli
$ ganache-cli

  • 2: Start ethereum-bridge
$ node bridge -H localhost:8545 -a 1

  • 3: Execute test of the smart-contracts (on the local)
    • Test for the ElectricityPriceOracle contract $ npm run test:oracle (truffle test ./test/test-local/ElectricityPriceOracle.test.js)

    • Test for the StreamingElectricityMarketplace contracts $ npm run test:streaming
      ($ truffle test ./test/test-local/StreamingElectricityMarketplace.test.js)



【References】



About

This is a smart contract that allow a buyer to be able to buy electricity⚡️ with subscription (streaming) plan.


Languages

Language:JavaScript 52.4%Language:Solidity 47.4%Language:Shell 0.2%Language:Batchfile 0.0%