© Barbu Angelo-Gabriel - angelo.barbu123@gmail.com - 2024
The Decentralised Energy Trading and Tracking System offers a highly secure and privacy-preserving system where energy resources can be traded, tracked and certified using a smart contract that facilitates the decentralized trading and tracking of energy resources between buyers and sellers. This contract supports creating buy and sell transactions, making offers, accepting offers, and ensuring secure fund transfers upon transaction completion.
-
Create Transaction:
- Buy Transaction: Created by a buyer with details like price, quantity, resource type, deadline, and auto-accept option.
- Sell Transaction: Created by a seller with similar details.
-
Add Offers:
- Participants can add offers to buy or sell transactions, specifying price and quantity.
-
Accept Offers:
- The buyer or seller can accept an offer. For buy transactions, the buyer's funds are withheld within the contract.
-
Update Transaction State:
- The state of a transaction can be updated through various stages such as Dispatched, InTransit, Delivered, PickedUp, and Completed.
-
Expire Transactions:
- Transactions can be expired after the deadline. If the auto-accept option is set, the best offer is automatically accepted.
- State Enum: Represents the various states a transaction can be in.
- Offer Struct: Contains details of an offer including offeror, price, quantity, and timestamp.
- Transaction Struct: Contains details of a transaction including buyer, seller, price, quantity, resource, dates, state, trace points, offers, deadline, and auto-accept option.
- Events: Various events like
NewTransaction
,StateChanged
,NewOffer
,OfferAccepted
, andResourcePickedUp
are emitted during the workflow.
- Node.js
- Truffle
- Ganache
- Install dependencies:
npm install
- Compile the smart contract:
truffle compile
- Deploy the contract to a local test network:
truffle migrate
- Run the tests:
truffle test
To deploy the smart contract to a live network:
-
Configure the
truffle-config.js
file with the desired network settings. -
Deploy the contract:
truffle migrate --network <network-name>
Work In Progress
Work In Progress