Installation
Environment Configuration
Configure your environment to differentiate between development, staging and production settings:
- Development Settings: Test network and configure the API to interact with mock data.
- Staging Settings: Test network and configure the API to interact with mock data. Reserved for environments that are deployed to a live server, but not yet production-ready.
- Production Settings: Set up connections to Stripe Api for handling live data and transactions.
Initial Configuration
-
Fork the Repository
- Fork the repository here: Request Network on GitHub
-
Database and API Configuration
- Configure the database and API settings:
-
Docker Compose Configuration
- Review and configure services using
docker-compose.yml
.
- Review and configure services using
-
Additional Configuration
- Configure encryption keys (used by CryptoJS to encrypt keys and secrets at rest):
ENCRYPTION_KEY=WANabc234=
IV_STRING=dxabcdeLAP333123abcLg==
- Set API and network configurations:
VALIDATOR_NAME=Your Validator Name
API_PORT=8080
API_HOST=http://localhost:8080
API_PREFIX=/api/v1
REQUEST_NETWORK_UI_URL=http://rn-staging.taoshi.io
orREQUEST_NETWORK_UI_URL=http://request.taoshi.io
for production
- Set Unkey verify URL:
UNKEY_VERIFY_URL=https://api.unkey.dev/v1/keys.verifyKey
- Configure encryption keys (used by CryptoJS to encrypt keys and secrets at rest):
Configuring Environment Variables
Registering as a Validator
Complete the registration through the Request Network Marketplace UI:
- Navigate to the Request Network Marketplace UI Validator Registration page:
- Authenticate using OAuth, authorize Request Network Marketplace to access your information, and set up your Validator Server.
- Click on Dashboard.
- Authenticate using OAuth to ensure secure access.
- Authorize Request Network Marketplace to access your information.
- Choose the account type as Validator.
- Enter your Validator Server’s base Url, which represents the instance you will spin up:
- Note: If the hosting details are not finalized, enter a placeholder and update it later.
- This Url will be automatically updated when you spin up your Validator Server instance.
API Keys and Endpoint Configuration
Upon completing the registration, you will receive an Api key and a secret, which are crucial for operating your Validator Server:
- API Key:
TAOSHI_API_KEY=api_abcdef
- Secret:
TAOSHI_VALIDATOR_API_SECRET=abc123456
These credentials allow you to authenticate incoming requests and manage interactions between your Validator Server and the Request Network Marketplace UI.
Setup and Configuration
Request Network Validator Server acts as a proxy between the consumer Api and the Validator Output Server (OPS). To establish this connection:
- Specify the OPS base URL in your
.env
file:VALIDATOR_OUTPUT_SERVER_API_URL=https://output-server-1:8080
- Data Flow:
- Consumer API Request: Sends a request to a specified endpoint received during the subscription to Validator services.
- Header Key:
x-taoshi-consumer-request-key
- ReqNet Processing: Receives and authenticates the consumer request, verifies ownership.
- ReqNet to OPS Request: Sends a request to the OPS with a header key
x-taoshi-validator-request-key
. - Communication Keys: Uses
x-taoshi-request-key
for communication between Request Network Marketplace UI and Validator Server.
Endpoint Creation
- A verified validator can register multiple endpoints, one per subnet, up to a total of 32 subnets (SN):
- Example endpoints:
/api/v1/user/:id
/api/v1/user/:id?min=1&max=50
/validator-checkpoint
- Example endpoints:
Output Server Connection
Set up the Validator Output Server (OPS) connection:
- Configure the OPS base URL in your
.env
file:- VALIDATOR_OUTPUT_SERVER_API_URL=https://output-server-url:8080
Deployment Workflow
- Local Deployment
- Build and run your Docker container locally:
- AWS Deployment
- Deploy using AWS Elastic Beanstalk:
General Deployment Information
The Validator Server can be deployed anywhere that supports Node.js, with or without Docker. At Taoshi, we deploy our own Validator Server on AWS ECS and Elastic Beanstalk. The project source code is set up with workflows for deployment to AWS ECS and/or AWS Elastic Beanstalk.
Deploying with AWS Elastic Beanstalk CLI (EB CLI)
Installation and Configuration
-
Install the EB CLI:
- Ensure that the EB CLI is installed on your machine. If it’s not, you can install it using pip:
- For detailed installation instructions, visit AWS EB CLI Installation.
-
Configure AWS Credentials:
- Before using the EB CLI, configure your AWS credentials. This setup is necessary to authenticate and communicate with AWS services:
- You will need to provide:
- AWS Access Key ID
- AWS Secret Access Key
- Default region name
- Default output format (optional)
-
Initialize Your Application:
- Navigate to the root directory of your application where the application’s code is located and run:
- You’ll be prompted to:
- Select the AWS region.
- Provide the name for your application.
- Choose the platform (e.g., Node.js, Python, Java, etc.).
- Decide whether to use CodeCommit.
- Set up SSH for instances if needed.
-
Create an Environment and Deploy:
- Once your application is initialized, create an Elastic Beanstalk environment and deploy your application:
- During this process, you will:
- Provide an environment name.
- Optionally configure more detailed settings like instance type, scaling options, etc.
- The
eb create
command will handle the provisioning of AWS resources (like EC2, RDS, etc.) and deploy your application.
-
Open Your Application:
- After the environment is created and your application is deployed, you can open it in a web browser:
- This command will automatically open the URL where your application is hosted.
-
Update Your Application:
- To update your application after making changes to the code, use:
- This command deploys the latest version of your application to the Elastic Beanstalk environment.
Once everything is setup, with EB, run:
Which should deploy your application to AWS EB under the account that’s tied the configured profile.
Payment Integration
When currency type of “Fiat” is selected during registration, payments are are facilitated and managed through Stripe Integration.
Stripe Payments
To enable Stripe payments you will need to create a Stripe account and store the credentials in your .env file.
- Go to stripe.com to register and create credentials.
- Complete registration to enable use account out of test mode and accept live payments.
- Store the credentials in your env file.
- For Stipe subscriptions to be updated properly webhooks need to be set up. A webhook configuration will need to be set up on the Stripe website that points at “https://<location of your api server>/webhooks.
**Command to test and enable Strip Payments**
Sentry Error Tracking
- Sentry error tracking can optionally be enabled by providing credentials. Got to https://sentry.io/ to configure.