The nCent Sandbox is a test environment for developers to emulate the upcoming nCent Core Protocol for the purposes of application development. In its current stage, it is designed with a Node.js backend with an Express server and a PostgreSQL database. While this architecture is clearly centralized by nature, it is merely a placeholder to allow developers to interact with our API and SDK, which will be directly transferable to our Core Protocol as it becomes available.
The following section is a quick reference of the Node.js models that comprise the nCent Sandbox
A wallet is simply the Stellar keypair implementation. We do not store private key information on our sandbox. A Wallet has the following attributes:
- uuid: the primary key, or unique identifier, for each Wallet
- address: the Stellar public key for the wallet
One of the unique aspects of the nCent Protocol is the ability for users to stamp NCNT tokens for the purposes of their specific use cases. TokenType is the model that tracks the various different stamped NCNT token types. This model has the following attributes:
- uuid: the primary key, or unique identifier, for each TokenType
- name: the title of the stamped token
- expiryDate: the expiration date of the stamped tokens
- sponsorUuid: the wallet address that was responsible for stamping the tokens, also known as the sponsor
- totalTokens: the total amount of tokens of this type that were stamped by the sponsor
A challenge can be thought of as the container for a set of stamped tokens. More specifically, a challenge is why a sponsor would stamp tokens in the first place. For example, a user might want to incentivize the hiring of an employee for a job role via referrals. The challenge would be to get a job candidate hired for the role. A challenge can be sponsored by a user, who will stamp tokens and attach them to the redemption of the challenge. Then, the challenge can be transferred to other users' wallets until one ultimately redeems the challenge. A Challenge has the following attributes:
- uuid: the primary key, or unique identifier, for each Challenge
- name: the title of the challenge
- expiration: the expiration date of the challenge (will usually correspond with the expiration date of the stamped tokens)
- rewardAmount: the maximum amount of stamped tokens that will be distributed among the participants along a provenance chain (more on this later)
- sponsorWalletAddress: the wallet address that was responsible for sponsoring the challenge
- isRedeemed: a boolean representing whether or not the challenge has been redeemed or not
Given our definition of a "Challenge" above, Transactions are a bit more self-explanatory. A transaction is simply the transfer model of a challenge between users via their Wallets. Transactions have the following attributes:
- uuid: the primary key, or unique identifier, for each Transaction
- parentTransaction: a foreign key pointing to the transaction that preceeded this one, should one exist
- amount: the number of tokens included in the transaction
- fromAddress: the wallet address of the sender of the challenge
- toAddress: the wallet address of the recipient of the challenge
First install docker locally: https://www.docker.com/products/docker-desktop
psql -U postgres
postgres=# SHOW config_file;
Navigate to your pg_hba.conf file and add this line:
host ncent-db all 172.17.0.0/16 trust
Navigate to your postgresql.conf file and change the following:
#listen_addresses = 'localhost'
to #listen_addresses = '*'
Change your postgres user's password to 'dickey'
createdb ncent-db
sh execDockerSetup.sh
if the migrations fail when running the shell script, stop the docker container (command listed below) and run the shell script again
From your local machine:
curl http://localhost:8010/api
{"message":"Welcome to the NCNT API!"}
curl http://localhost:8010/api/wallets
[]
To view the logs of the docker container:
docker logs sandboxContainer
docker rm -f sandboxContainer
First, make sure your docker container is not running via the above command
dropdb ncent-db
createdb ncent-db
Navigate to your server folder and run:
../node_modules/.bin/sequelize db:migrate
Navigate to your main directory and run:
npm run test
We also have our own instance of the sandbox hosted on AWS via Elastic Container Service. To access its APIs, simply add the routes detailed in the endpoints section below to the IP Address and port of our hosted instance: http://18.219.110.45:8010/api
The Sandbox API routes are detailed here.
- Get All Wallets
- Get Wallet
- Get Wallet Balance
- Stamp Token
- Get All TokenTypes
- Get TokenType
- Get All Challenges
- Get Challenge
- Create Challenge
- Retrieve Sponsored Challenges
- Retrieve Held Challenges
- Get All Transactions
- Share Challenge
- Redeem a Challenge
- Retrieve Provenance Chain of a Transaction
- Retrieve Provenance Chain (FIFO)
Retrieve information about all wallets.
None
None
Retrieve information about a specific wallet
Name | Type | Description |
---|---|---|
address | String | Valid wallet public key |
None
Retrieve information about how much of a specific token a wallet holds
Name | Type | Description |
---|---|---|
address | String | Valid wallet public key |
tokenTypeUuid | String | Valid TokenTypeUUID |
None
Instantiate a new token type. In the current implementation, this creates new tokens from nothing. In production, one can only stamp NCNT into a new TokenType
None
Name | Type | Description |
---|---|---|
sponsorUuid | String | Valid public key of token sponsor |
name | String | Token Name |
totalTokens | Int | Number of tokens to be stamped |
expiryDate | Date Object | The expiration date of the tokens stamped into existance |
Lists all token types and the transactions associated with them
None
None
Lists information about a specific token type and the transactions associated with it
Name | Type | Description |
---|---|---|
tokenTypeUuid | String | Unique identifier for a specific token type |
None
Retrieves a list of all challenges that have been created and their corresponding attributes
None
None
Lists information about a specific challenge
Name | Type | Description |
---|---|---|
challengeUuid | String | Unique identifier for a specific challenge |
None
Creates a challenge from a sponsor's wallet address.
Name | Type | Description |
---|---|---|
address | String | Valid sponsor wallet address |
Name | Type | Description |
---|---|---|
name | String | the name of the challenge |
expiration | Date | the expiration date of the challenge |
tokenTypeUuid | UUID | the primary key of the token type that will be included in the challenge |
rewardAmount | Int | Amount of tokens to be distributed in the rewards for the challenge |
signed | String | JSON string of signed message object |
Retrieves all challenges sponsored by a specific wallet address.
Name | Type | Description |
---|---|---|
sponsorWalletAddress | String | Valid Wallet address |
Name | Type | Description |
---|---|---|
None |
Retrieves all challenges currently possessed (but not sponsored) by a specific wallet address.
Name | Type | Description |
---|---|---|
holderWalletAddress | String | Valid Wallet address |
Name | Type | Description |
---|---|---|
None |
Gets all transactions
none
none
Shares a challenge via a transaction from one wallet to another
Name | Type | Description |
---|---|---|
challengeUuid | String | Unique identifier for a specific challenge to be transferred |
Name | Type | Description |
---|---|---|
fromAddress | String | Valid public key of sender |
toAddress | String | Valid public key of receiver |
signed | String | JSON string of signed message object |
Redeems a challenge from a wallet
none
Name | Type | Description |
---|---|---|
challengeUuid | Int | Unique identifier for the challenge that is to be redeemed |
signed | String | JSON string of signed message object (signed by the Challenge sponsor) |
Retrieves the provenance of a transaction via its parentTransactions
Name | Type | Description |
---|---|---|
transactionUuid | String | Unique identifier for a specific transaction |
none
Retrieves the provenance of a publicKey's first owned challenge of a specific TokenType
Name | Type | Description |
---|---|---|
address | String | Valid Wallet public key |
tokenTypeUuid | String | Valid UUID of a TokenType |
none