The ecash is an open source electronic cash library that allows developers to create ecash platform to facilitate the locating and transfer of ecash between benefactors and beneficiaries.
Note: This repository is not capable of creating ecash, only the ecash virtual location is stored in the device so that no one is capable of tampering the ecash data.
This is a demo open source electronic cash app that allows the transfer of ecash between mobile or desktop devices, ensuring ecash data security, transaction anonymity and prevent fraud like double spending using the entrophy chaos algorithm to transfer ecash data between devices, in this repository includes the electronic cash storage (see sample: https://ecash-demo.web.app) and supply (see sample: https://ecash-dummy.web.app) to develop and test your electronic cash storage app.
This repository is straighforward and simple and can be use as the foundation for complex e-cash systems development.
What separates this electronic cash from cryptos and other digital payment, this app was developed for future purpose to handle massive wealth in preparation for off grid and off planet economies, the concept was cenceived from the idea of space economy as the existing digital currencies do not posses. This electronic cash is intended to solve the basic necessities of electronic economies.
For web developers and designers we welcome and invite you to collaborate with us creating electronic cash front end and back end features, for better user experiences, let us know if when you need to develop the optical transfer of demo ecash, we will provide demo ecash upon request.
- Create your frond end (using Figma, Wordpress, Laravel or just plane HTML coding).
- Interface the electronic cash using the example in the public folder.
For the hackers and other enthusiasts we invite you to find vulnerabilities, loop holes or bugs in this system to further improve and enhance the electronic cash data securities, please do share your found vulnerabilities loop holes and bugs, we would specifically ask you to tampered the electronic cash in demonstration by video or other means:
Challenges:
- Make an instance of changing the dummy ecash amount (ex. make the DMY 1,...000.00 to 2,...000.00 or any amount).
- Duplicate an account to any number of cloned accounts, spend one and then spend the next clones (to see if we can do a double spending instance).
- Change the currency (example the currency is DMY change into USD or the currency of your choice).
- Transfer an account ecash data (steal) to a newly created account.
The electronic cash repository implements a basic electronic cash system, this project allows ecash transfers and storage for users to conduct secure and anonymous transactions without relying on a central authority or server.
Here's a breakdown of how use the repository:
Core Components Cash Creation and Minting:
The ecash does not create ecash, it has no capability to create ecash, instead it can split and transfer ecash to a beneficiary device.
Security elements: The system relies on enthrophy chaos algorithm to store and ensure that e-cash secured and can only be transferred by the device it resides in. The e-cash is designed to be anonymous and secured. transactions are signed with private keys to ensure authenticity and prevent double-spending.
Transactions: The transactions are the core of the system. When one user wants to transfer e-cash to another, the transfer process involves verifying the authenticity of the funds being transferred and updating the balance of both users.
Spending and Verification: Once e-cash is received, the holder can spend it. This involves splitting and transferring the ecash to another user or device that uses the same backend. The system verifies whether the ecash are valid and if the transaction can be executed without double-spending.
Double Spending Prevention: To prevent the same digital cash from being spent multiple times (a problem called "double-spending"), the system typically keeps a record of spent e-cash and checks against this to ensure that a user doesn’t spend the same ecash more than once.
Offline Transactions: The system simulates offline transactions where users can transfer ecash without being online, using locally stored records (e.g., local databases or files). Once the system comes online, the transaction records are synchronized with the central ledger or server.
ECash backend usage (iframe)
let iframe = document.createElement("iframe");
iframe.src = "https://ecash-icons.web.app";
document.body.appendChild(iframe);
iframe.onload = function() {
// ecash is ready
};
How to send message request to the ecash backend (iframe)
function readBalance() {
iframe.contentWindow.postMessage({ action: "ecash-api-read-balance" }, iframe.src);
};
function readAccount() {
iframe.contentWindow.postMessage({ action: "ecash-api-read-account" }, iframe.src);
};
window.hashAccount = function(d) {
iframe.contentWindow.postMessage({ action: "ecash-api-hash-account" }, iframe.src);
};
window.scanQRCode = function(d) {
iframe.contentWindow.postMessage({ action: "ecash-api-hash-assemble", qrScan: qrScan }, iframe.src);
};
-
Transfer ecash - first scan the beneficiary QR code and then set the amount, if the amount is valid the ecash QR code will display in rapid successing for fast transfer
iframe.contentWindow.postMessage({
action: "ecash-api-transfer-amount",
currency: document.querySelector(".beneficiary-currency").value,
range: document.querySelector(".beneficiary-amount").value
},
iframe.api.src
);
How to receive message from the ecash (iframe) - after the ecash (iframe) processing the request it will return the result back to your app, you can receive the result by adding a event listerner as shown below:
window.addEventListener("message", () => {
if (e.data.action && e.data.action.match(/(ecash-api)/)) {
if (e.data.action && e.data.action.match(/(ready)/)) {
readBalance();
readAccount();
};
if (e.data.action && e.data.action.match(/(response)/)) {
apiResponses({ data: e.data });
};
};
});
function apiResponses(data) {
data = data.data;
if (data.action && data.action.match(/(read-balance)/)) {
document.querySelector(".ex-balance").innerHTML = data.balance;
};
if (data.action && data.action.match(/(read-account)/)) {
for (let i = 0, j = ["name", "number", "protocol"]; i < j.length; i++)
document.querySelector(".account-" + j[i]).innerHTML = data.account[j[i]] ? data.account[j[i]] : "***";
};
if (data.action && data.action.match(/(hash-account)/)) {
createQr({
s: data.hash
});
};
if (data.action && data.action.match(/(hash-fragment)/)) {
for (let i = 0; i < data.hash.length; i++) drawQr({ id: ".qr-cont", piece: data.hash[i] });
let cvs = { e: [], i: 0 };
for (let i = 0, j = document.querySelector(".qr-cont").getElementsByTagName("canvas"); i < j.length; i++) {
j[i].style.display = "none";
j[i].style[window.innerWidth < window.innerHeight ? "width" : "height"] = "75%";
cvs.e.push(j[i]);
};
if (cvs.e.length > 1) autoSlide({ t: delay });
document.getElementById("show-qr-cont").style.display = "block";
};
if (data.action && data.action.match(/(hash-assemble)/)) {
let d = JSON.parse(data.object);
if (d.r) {
if (d.r && d.ah) {
document.querySelector(".beneficiary-name").innerHTML = d.ah.name;
document.querySelector(".beneficiary-number").innerHTML = d.ah.number;
document.querySelector(".beneficiary-currency").innerHTML = d.ah.currency;
};
if (d.l) {
if (d.r && d.l.amount > 0) {
alert(`Electronic Cash ${d.l.currency}${d.l.amount}`);
readBalance();
} else alert(`Electronic Cash is Spent`);
}
} else alert(`Wrong QR`);
};
if (data.action && data.action.match(/(transfer-amount)/)) {
createQr({ s: data.hash });
};
if (data.action && data.action.match(/(dialog-message)/)) {
if (data.message == "m001") alert("There is no benificiary");
};
};
For development use the dummy electronic cash to test transfer from one device to another while developing your ecash front and back end.
You can get dummy electronic cash from https://ecash-dummy.web.app
No need to enter username or password just click the button "Log in".
Click the button "Scan QR" - open your app or try https://ecash-demo.web.app or https://qpod-demo.web.app transferring dummy ecash into your account.
For https://ecash-demo.web.app find the button "Show QR" and click.
For https://qpod-demo.web.app scroll down and find the button "Claim" and click.
Scan your app or https://ecash-demo.web.app or https://qpod-demo.web.app account QR codes until the dialog below appears.
When the dialog above appears click the button "Release" to release the dummy electronic cash QR codes.
Scan the dummy ecash QR codes until a dialog appears "You have received a dummy ecash amount DMY 1,..0.00
During your app development make sure you set the "offline to flase" to disable your caching.
let offline: !1; or let offline: false;
or comment out the cache service lines;
if (navigator.onLine && offline && "serviceWorker" in navigator) {
navigator.serviceWorker
.register("index.js")
.then((registration) => {})
.catch((err) => {});
};
We look forward to see your ecahs apps and get it become a a working electronic cash platform.
Enjoy!