This holds the offchain components of the Circles API
# clone and set up submodules
git clone
cd circles-api
git submodule update --init
# install
npm install
# install contracts
cd contracts
npm install
# set up blockchain
npm run ganache
# deploy contracts
npx truffle compile
npx truffle migrate --reset --compile-all
# use truffle console
npx truffle console
> let hf = await HubFactory.deployed()
> let s = await hf.spawn(1736111111111111, 0, 'CRC', 3600, 100)
// hotreloading should work
npm run dev
Get in touch with @ana0 or @edzillion to get these env vars.
# General
LOG_LEVEL=debug
NODE_ENV=test
API_VERSION=v1.1.2
# Cognito
COGNITO_POOL_ID=
COGNITO_POOL_REGION=
COGNITO_CLIENT_ID_API=
COGNITO_CLIENT_ID_MOBILE=
COGNITO_TEST_USERNAME=
COGNITO_TEST_PASSWORD=
COGNITO_POOL_JWT_KID=
COGNITO_POOL_JWT_N=
# SNS
ANDROID_GCM_PLATFORM_ARN=
# Database
PGUSER=
PGPASSWORD=
PGHOST=
PGPORT=
PGDATABASE=
# Blockchain
NETWORK_ID=
HUB_CONTRACT_ADDRESS=
PRIVATE_KEY=
# For scripts
AWS_REGION=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AUTH_ACCESS_TOKEN= //generated by saveCognitoTokenToEnvFile.js
Api authenication is managed by accesstoken
sent in the response headers
npm run token
will generate a valid token
CRUD app for user and organization profiles
DELETE /notifs/:notifId
Name | Type | Description |
---|---|---|
notifId | Number | Notification Id. |
Name | Type | Description |
---|---|---|
None | Returns nothing on success. |
GET /notifs/
Name | Type | Description |
---|---|---|
created_at | Date | Record creation date. |
description | String | Notification text. |
dismissed | Boolean | Has this Notification been dismissed? |
id | Number | Id of the Notification (ascending integer). |
owner_id | String | User Id of the Notification owner. |
updated_at | Date | Record update date. |
PUT /notifs/:notifId
Name | Type | Description |
---|---|---|
notifId | Number | Notification Id. |
Name | Type | Description |
---|---|---|
created_at | Date | Record creation date. |
description | String | Notification text. |
dismissed | Boolean | Has this Notification been dismissed? |
id | Number | Id of the Notification (ascending integer). |
owner_id | String | User Id of the Notification owner. |
updated_at | Date | Record update date. |
DELETE /offers/:offerId
Name | Type | Description |
---|---|---|
offerId | Number | Offer Id. |
Name | Type | Description |
---|---|---|
None | Returns nothing on success. |
GET /offers/
Name | Type | Description |
---|---|---|
amount | Number | The amount of an item offered. |
category | String | The category of item offered. |
created_at | Date | Record creation date. |
description | String | Offer description. |
id | Number | Id of the Offer (ascending integer). |
item_code | String | Item code for linking with POS systems. |
owner_id | String | User Id of the Offer owner. |
percentage | Number | Percentage of Offer to be paid in Circles (multiple of 0.1). |
price | Number | Price of Offer in Circles (multiple of 0.1). |
public | Boolean | Is this Offer publicly viewable? |
title | String | The title of the Offer. |
type | Enum | The type of Offer {'ITEM', 'PERCENTAGE_ITEM', 'PERCENTAGE_CATEGORY'}. |
updated_at | Date | Record update date. |
POST /offers/
Name | Type | Description |
---|---|---|
amount | Number | The amount of an item offered. |
category | String | The category of item offered. |
created_at | Date | Record creation date. |
description | String | Offer description. |
id | Number | Id of the Offer (ascending integer). |
item_code | String | Item code for linking with POS systems. |
owner_id | String | User Id of the Offer owner. |
percentage | Number | Percentage of Offer to be paid in Circles (multiple of 0.1). |
price | Number | Price of Offer in Circles (multiple of 0.1). |
public | Boolean | Is this Offer publicly viewable? |
title | String | The title of the Offer. |
type | Enum | The type of Offer {'ITEM', 'PERCENTAGE_ITEM', 'PERCENTAGE_CATEGORY'}. |
updated_at | Date | Record update date. |
PUT /offers/:offerId
Name | Type | Description |
---|---|---|
offerId | Number | Offer Id. |
Name | Type | Description |
---|---|---|
amount | Number | The amount of an item offered. |
category | String | The category of item offered. |
created_at | Date | Record creation date. |
description | String | Offer description. |
id | Number | Id of the Offer (ascending integer). |
item_code | String | Item code for linking with POS systems. |
owner_id | String | User Id of the Offer owner. |
percentage | Number | Percentage of Offer to be paid in Circles (multiple of 0.1). |
price | Number | Price of Offer in Circles (multiple of 0.1). |
public | Boolean | Is this Offer publicly viewable? |
title | String | The title of the Offer. |
type | Enum | The type of Offer {'ITEM', 'PERCENTAGE_ITEM', 'PERCENTAGE_CATEGORY'}. |
updated_at | Date | Record update date. |
DELETE /orgs/:orgId
Name | Type | Description |
---|---|---|
orgId | String | Organization UUID. |
Name | Type | Description |
---|---|---|
None | Returns nothing on success. |
GET /orgs/:orgId
Name | Type | Description |
---|---|---|
orgId | String | Organization UUID. |
Name | Type | Description |
---|---|---|
address | String | Organisation address. |
agreed_to_disclaimer | Boolean | Legal requirement. |
created_at | Date | Record creation date. |
description | String | Organization tagline. |
String | Email of the Organization. |
|
id | String | UUID of the Organization. |
last_active | Date | Last date Organization was active. |
latitude | Float | Latitude of Organization |
longitude | Float | longitude of Organization |
organization_name | String | Display name of Organization. |
owner_id | String | User Id of the Organization owner. |
profile_pic_url | String | Url of profile pic (stored on S3). |
updated_at | Date | Record update date. |
GET /orgs/
Name | Type | Description |
---|---|---|
address | String | Organisation address. |
agreed_to_disclaimer | Boolean | Legal requirement. |
created_at | Date | Record creation date. |
description | String | Organization tagline. |
String | Email of the Organization. |
|
id | String | UUID of the Organization. |
last_active | Date | Last date Organization was active. |
latitude | Float | Latitude of Organization |
longitude | Float | longitude of Organization |
organization_name | String | Display name of Organization. |
owner_id | String | User Id of the Organization owner. |
profile_pic_url | String | Url of profile pic (stored on S3). |
updated_at | Date | Record update date. |
Create Organization record (201) or return if exists (200)
POST /orgs/
Name | Type | Description |
---|---|---|
address | String | Organisation address. |
agreed_to_disclaimer | Boolean | Legal requirement. |
created_at | Date | Record creation date. |
description | String | Organization tagline. |
String | Email of the Organization. |
|
id | String | UUID of the Organization. |
last_active | Date | Last date Organization was active. |
latitude | Float | Latitude of Organization |
longitude | Float | longitude of Organization |
organization_name | String | Display name of Organization. |
owner_id | String | User Id of the Organization owner. |
profile_pic_url | String | Url of profile pic (stored on S3). |
updated_at | Date | Record update date. |
PUT /orgs/:orgId
Name | Type | Description |
---|---|---|
orgId | String | Organization UUID. |
Name | Type | Description |
---|---|---|
address | String | Organisation address. |
agreed_to_disclaimer | Boolean | Legal requirement. |
created_at | Date | Record creation date. |
description | String | Organization tagline. |
String | Email of the Organization. |
|
id | String | UUID of the Organization. |
last_active | Date | Last date Organization was active. |
latitude | Float | Latitude of Organization |
longitude | Float | longitude of Organization |
organization_name | String | Display name of Organization. |
owner_id | String | User Id of the Organization owner. |
profile_pic_url | String | Url of profile pic (stored on S3). |
updated_at | Date | Record update date. |
DELETE /users/
Name | Type | Description |
---|---|---|
None | Returns nothing on success. |
POST /users/contacts
Name | Type | Description |
---|---|---|
contacts | Object[] | List of contacts that are Circles users. |
contacts.id | String | Phone specific contact Id. |
contacts.number | String | Phone number of contact. |
GET /users/
Name | Type | Description |
---|---|---|
agreed_to_disclaimer | Boolean | Legal requirement. |
created_at | Date | Record creation date. |
device_endpoint | String | Notification endpoint. |
device_id | String | Device Id of phone. |
display_name | String | Full name of the User. |
String | Email of the User. |
|
id | String | UUID of the User. |
phone_number | String | Phone number of the User. |
profile_pic_url | String | Url of profile pic (stored on S3). |
updated_at | Date | Record update date. |
username | String | Username of the User. |
Create User record (201) or return if exists (200)
POST /users/
Name | Type | Description |
---|---|---|
agreed_to_disclaimer | Boolean | Legal requirement. |
created_at | Date | Record creation date. |
device_endpoint | String | Notification endpoint. |
device_id | String | Device Id of phone. |
display_name | String | Full name of the User. |
String | Email of the User. |
|
id | String | UUID of the User. |
phone_number | String | Phone number of the User. |
profile_pic_url | String | Url of profile pic (stored on S3). |
updated_at | Date | Record update date. |
username | String | Username of the User. |
PUT /users/
Name | Type | Description |
---|---|---|
agreed_to_disclaimer | Boolean | Legal requirement. |
created_at | Date | Record creation date. |
device_endpoint | String | Notification endpoint. |
device_id | String | Device Id of phone. |
display_name | String | Full name of the User. |
String | Email of the User. |
|
id | String | UUID of the User. |
phone_number | String | Phone number of the User. |
profile_pic_url | String | Url of profile pic (stored on S3). |
updated_at | Date | Record update date. |
username | String | Username of the User. |