An on-chain affiliate marketing platform, rewarding users in XPR for referring and registering on Proton.
Production Instance: earnproton.com
Proton mainnet instance deploys the main
branch of this repository.
Development Instance: test.earnproton.com
Proton testnet instance deploys the dev
branch of this repository.
This application features the following tech stack :
- React JS : A Front End Web Application Framework.
- Hapi : Node JS HTTP API.
- Demux : Deterministic event-sourced state and side effect handling.
- Hasura : GraphQL Engine for PostgreSQL Database.
- KEOSD : Wallet service daemon for storing private keys and signing digital messages.
- EOSIO : Blockchain protocol with industry-leading transaction speed.
- Kubernetes : Docker Container Orchestration.
The affiliate smart contract will store referral info, validation info, and issue rewards for a successfully validated referral.
For more information on the smart contract design for thi POC please see the smart contract readme.
Demux is a backend infrastructure pattern for sourcing blockchain events to deterministically update queryable datastores and trigger side effects.
We use the demux pattern's ability for blockchain events to trigger new transactions, as well as other side effects outside of the blockchain. The blockchain as the single source of truth for all application state
Backend services execute the following smart contract actions triggered by demux updaters. The custom permission affiliate@verify
is created for the smart contract account so that keys stored in wallet service can can only call the following actions.
-
Account Registration Triggers
verifyacc
action that updates referral when invitee registers a new account. -
Account KYC Triggers
verifykyc
action that updates referral when invitee completes KYC for a new account.
- Client sends transaction to blockchain
- Action Watcher invokes Action Reader to check for new blocks
- Action Reader sees transaction in new block, parses actions
- Action Watcher sends actions to Action Handler
- Action Handler processes actions through Updaters and Effects
- Actions run their corresponding Updaters, updating the state of the Datastore
- Actions run their corresponding Effects, triggering external events
- Client queries API for updated data
Somethings you need before getting started:
Copy the .env.example
then update the environment variables according to your needs.
cp .env.example .env
- Clone this repo using
git clone --depth=1 https://github.com/edenia/proton-affiliate.git <YOUR_PROJECT_NAME>
. - Move to the appropriate directory:
cd <YOUR_PROJECT_NAME>
. - Run
make run
in order to start the project using docker compose.
At this point you can navigate to http://localhost:3000
.
Within this repository you will find the following directories and files:
.
├── contracts ..................... EOSIO Smart Contracts
│ └── affiliate ................. Affiliate Platform Contract
├── docs .......................... Documentation
│ └── img ....................... Images and Diagrams
├── hapi .......................... Node JS backend & HTTP API
│ └── src
│ └── config ................ Backend Configurations
│ └── routes ................ HTTP routes
│ └── utils ................. Utilities and Libraries
│ └── services .............. Project Business Logic
| └── hyperion .......... Demux Implementation
├── hasura ........................ Hasura GraphQL Engine
├── kubernetes .................... Kubernetes Manifests
├── utils ......................... Makefiles for project build
├── wallet ........................ EOSIO Wallet Service
└── webapp ........................ ReactJS Web Application
This project is being developed on the Proton Testnet using the affiliate
smart contract account. The backend service is currently using EOS Costa Rica's testnet API Node
We use the EOS JS javascript API for integration with EOSIO-based blockchain networks using EOSIO RPC API.
EOS JS documentation can be found here
This FullStack Template uses React.js as a Frontend Library which together with other tools like Apollo Client, GraphQL and Material UI brings a robust solution for building Single Page Applications out of the box.
Hasura technology maps a PostgreSQL database and provides a reliable and easy-to-use API. This allow us to focus on critical features of our projects, delegating mechanic CRUD (Create, Read, Update, Delete) operations. Hasura also enables custom REST handling capabilities with the possibility to integrate a custom REST server, that way we can extend the base CRUD functionalities and build custom business logic.
We need to handle REST custom requests coming from the Hasura GraphQL server. For this, we use hapi.dev, which is a simple and easy-to-use backend framework.
MIT © Sistemas Edenia Internacional S.A..
Please read Edenia's Open Source Contributing Guidelines.
Please report bugs big and small by opening an issue
Edenia runs independent blockchain infrastructure and develops web3 solutions. Our team of technology-agnostic builders has been operating since 1987, leveraging the newest technologies to make the internet safer, more efficient, and more transparent.