{"activeVersionTag":"latest","latestAvailableVersionTag":"latest","collection":{"info":{"_postman_id":"c30e327e-9359-4d39-8ad3-121a9a10bbf9","name":"STACS Platform APIs","description":"## 1. Introduction\nThe STACS Platform Suite comprises of 2 platforms \n1. STACS Managed Account Service (KMS)\n2. STACS Blockchain Platform \n\nThis 1-stop service provides API access to both the STACS Blockchain and the key management infrastructure required for managing wallets and authenticating transactions on the blockchain. \n\n## 2. Security Setup\nBoth platforms are using [OAuth2.0 Authorization Code Grant](https://oauth.net/2/grant-types/authorization-code/) for authentication and authorization.\nThe authorization code flow is a 3-legged configuration where the end user is provided with an authorization code that is exchanged for an access token.\nMore details can be found on the OAuth security setup from this [AWS Cognito article](https://aws.amazon.com/blogs/mobile/understanding-amazon-cognito-user-pool-oauth-2-0-grants/).\n\n## 3. STACS Managed Account Service (KMS) \nThe STACS Managed Account Service (KMS) is a cloud-based user account and private key management solution that enables easy interaction with the STACS Blockchain platform. \nUser accounts can be created and mapped to multiple wallets belonging to the same user. \n\nSignature generation from a user wallet is also managed by the Account Service and is mandatory when interfacing with the STACS Blockchain for authentication and authorization. \n\nSignatures can be generated by sending the txData payload of the blockchain API to the ```/KMSService/sign``` endpoint which returns the txSignature field. \n\n#### 3.1 Account Service Setup with AWS \nA wallet comprises of an asymmetric key-pair which has a public key and a private key. \nThe STACS Managed Account Service leverages on the security and resiliency of AWS KMS to manage the full lifecycle of private keys ranging from key creation to signature generation.\n\nAPIs listed here also provide a simple way to manage accounts with AWS Cognito. Private keys are safely kept within AWS KMS where they are never exposed.\nEach account created is able to support multiple wallet addresess and corresponding private keys (32-byte string of random characters).\n\nPrivate keys for the STACS Blockchain are created using the the Elliptic Curve Digital Signature Algorithm (ECDSA) which utlizes the secp256k1 algorithm provided by AWS KMS.\n \nSignatures for API requests sent to the STACS blockchain are generated with the /KMSService/sign endpoint for registered users. The payload sent to this endpoint is the entire txData payload for relevant Blockchain APIs and the txSignature field is returned synchronously to be combined with the txData as a JSON field for submission to the STACS Blockchain platform. \n\nNote that user creation requires an admin role user that is not part of the scope of these APIs. \n\n*The STACS Managed Account Service will be available in the future as a simple AWS deployment package that you could setup within your AWS environment.*\n\n## 4. STACS Blockchain Platform\nThe STACS Blockchain Platform is a private permissioned network running on the STACS Blockchain technology (Enhanced Ethereum). \n\nWhile the STACS Blockchain utilizes the standard Ethereum Virtual Machine (EVM), enhancements have been made to core layers ranging from Consensus (removal of the energy intensive Proof of Work), addition of an Access Control Management layer and On-Chain Functions which offload complex processing from the smart contract layer into the node. \n\nSolidity Smart Contracts can be deployed as is on the STACS Blockchain with the highest supported version of Solidity  being 0.7.9.\n\nAsynchronous callbacks are also supported where confirmation of transactions on the blockchain are sent to the registered subscribers. \n\n## 5. Tutorial - deploying your first smart contract\n#### 5.1 Pre-requisite Checks\nOnce you have secured the components as stated in the Pre-requisite section, you can test connectivity by calling the endpoint ```/block/latestHeight```.\nA HTTP 200 response with the latest block number in the Studios environment reflected indicates that your setup is successful.\n\n#### 5.2 Access Control Description\nThe STACS Blockchain implements an Access Control layer where you are first required to create \n1. Wallet Permission Tag\n2. Smart Contract Access (SCA)\n\nOnce the Access Control layer elements have been created, you can proceed to deploy the smart contract template code to the blockchain. \nFor future deployments of the same smart contract template code, you may reuse the same Wallet Permission Tags and SCA.\n\n#### 5.3 Creating Permission Tag and Adding your User Wallet Address \nYou will need to define 1 or more Wallet Permission Tags that indicate a group of wallet addresses are eligible to interact with the functions of the smart contract code you are about to deploy. \n\n1. Create a single permission tag with the endpoint ```/nodefunction/permission```.\n2. Tag your user wallet address with the endpoint ```/nodefunction/permission/walletAddress/add```.\n3. Verify that your wallet address has been tagged successfully on the blockchain with the endpoint ```/nodefunction/permission/walletAddress```\n\n#### 5.4 Select Smart Contract Code Template\nSmart Contract code is uploaded to the node directly by node operators and provided as templates for API users. \n\n1. Retrieve the list of available templates using the endpoint ```/smartcontracts/templates``` and note down the templateId\n2. Retrieve the list of public functions of the template with the endpoint ```/smartcontracts/contracts/{templateId}``` for later use.\n\n#### 5.5 Define Access Control with SCA\nSCA definition requires a wallet permission tag to be pre-created and the list of public functions of the smart contract template you are deploying.\nYou may leave the Policy field blank to utilize the default Network Governance Policy setting. \n\n1. Run the endpoint ```/nodefunction/contractAccess``` to create a SCA template and note down the scaId\n2. Verify that your SCA is created on the blockchain with the endpoint ```/nodefunction/contractAccess/confirmation```\n\nThis newly created SCA can be reused for deploying smart contracts of the same template.\n\n#### 5.6 Deploying the Smart Contract \n\nAs you have selected your smart contract in the previous step and noted down the template Id, construct the request field according to your needs.\n\n1. Run the endpoint ```/smartcontracts/create``` to deploy the smart contract code template with your SCA\n2. Verify that your smart contract has been deployed with the endpoint ```/smartcontracts/create/confirmation```\n\nCongratulations! \n\nYou have deployed your first smart contract!\n\nTo interact with your smart contract, proceed to use either the ```/smartcontracts/invoke``` endpoint to update the smart contract state (e.g. transfer of tokens) or the ```/smartcontracts/query``` to retrieve the latest smart contract state details (e.g. wallet balance). \n\n## 6. Pre-requisites to get started:\nEach platform will require its own API Key and OAuth2.0 setup on your end.\n\nThe API Key will be required to be submitted in the header as 'x-api-key'\nFor OAuth2.0, you will need:\n- client id\n- client secret\n- login credentials\n\nPlease contact us at info@stacs.io for more information on the onboarding process for the Studios Environment. \n","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","isPublicCollection":false,"owner":"11548940","collectionId":"c30e327e-9359-4d39-8ad3-121a9a10bbf9","publishedId":"UVyxRE45","public":true,"publicUrl":"https://apidocs.stacs.io","privateUrl":"https://go.postman.co/documentation/11548940-c30e327e-9359-4d39-8ad3-121a9a10bbf9","customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"documentationLayout":"classic-double-column","customisation":null,"version":"8.10.1","publishDate":"2022-05-13T06:56:57.000Z","activeVersionTag":"latest","documentationTheme":"light","metaTags":{},"logos":{}},"statusCode":200},"environments":[],"user":{"authenticated":false,"permissions":{"publish":false}},"run":{"button":{"js":"https://run.pstmn.io/button.js","css":"https://run.pstmn.io/button.css"}},"web":"https://www.getpostman.com/","team":{"logo":"https://res.cloudinary.com/postman/image/upload/t_team_logo_pubdoc/v1/team/768118b36f06c94b0306958b980558e6915839447e859fe16906e29d683976f0","favicon":"https://stacs.io/favicon.ico"},"isEnvFetchError":false,"languages":"[{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"HttpClient\"},{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"RestSharp\"},{\"key\":\"curl\",\"label\":\"cURL\",\"variant\":\"cURL\"},{\"key\":\"dart\",\"label\":\"Dart\",\"variant\":\"http\"},{\"key\":\"go\",\"label\":\"Go\",\"variant\":\"Native\"},{\"key\":\"http\",\"label\":\"HTTP\",\"variant\":\"HTTP\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"OkHttp\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"Unirest\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"Fetch\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"jQuery\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"XHR\"},{\"key\":\"c\",\"label\":\"C\",\"variant\":\"libcurl\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Axios\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Native\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Request\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Unirest\"},{\"key\":\"objective-c\",\"label\":\"Objective-C\",\"variant\":\"NSURLSession\"},{\"key\":\"ocaml\",\"label\":\"OCaml\",\"variant\":\"Cohttp\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"cURL\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"Guzzle\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"HTTP_Request2\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"pecl_http\"},{\"key\":\"powershell\",\"label\":\"PowerShell\",\"variant\":\"RestMethod\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"http.client\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"Requests\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"httr\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"RCurl\"},{\"key\":\"ruby\",\"label\":\"Ruby\",\"variant\":\"Net::HTTP\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"Httpie\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"wget\"},{\"key\":\"swift\",\"label\":\"Swift\",\"variant\":\"URLSession\"}]","languageSettings":[{"key":"csharp","label":"C#","variant":"HttpClient"},{"key":"csharp","label":"C#","variant":"RestSharp"},{"key":"curl","label":"cURL","variant":"cURL"},{"key":"dart","label":"Dart","variant":"http"},{"key":"go","label":"Go","variant":"Native"},{"key":"http","label":"HTTP","variant":"HTTP"},{"key":"java","label":"Java","variant":"OkHttp"},{"key":"java","label":"Java","variant":"Unirest"},{"key":"javascript","label":"JavaScript","variant":"Fetch"},{"key":"javascript","label":"JavaScript","variant":"jQuery"},{"key":"javascript","label":"JavaScript","variant":"XHR"},{"key":"c","label":"C","variant":"libcurl"},{"key":"nodejs","label":"NodeJs","variant":"Axios"},{"key":"nodejs","label":"NodeJs","variant":"Native"},{"key":"nodejs","label":"NodeJs","variant":"Request"},{"key":"nodejs","label":"NodeJs","variant":"Unirest"},{"key":"objective-c","label":"Objective-C","variant":"NSURLSession"},{"key":"ocaml","label":"OCaml","variant":"Cohttp"},{"key":"php","label":"PHP","variant":"cURL"},{"key":"php","label":"PHP","variant":"Guzzle"},{"key":"php","label":"PHP","variant":"HTTP_Request2"},{"key":"php","label":"PHP","variant":"pecl_http"},{"key":"powershell","label":"PowerShell","variant":"RestMethod"},{"key":"python","label":"Python","variant":"http.client"},{"key":"python","label":"Python","variant":"Requests"},{"key":"r","label":"R","variant":"httr"},{"key":"r","label":"R","variant":"RCurl"},{"key":"ruby","label":"Ruby","variant":"Net::HTTP"},{"key":"shell","label":"Shell","variant":"Httpie"},{"key":"shell","label":"Shell","variant":"wget"},{"key":"swift","label":"Swift","variant":"URLSession"}],"languageOptions":[{"label":"C# - HttpClient","value":"csharp - HttpClient - C#"},{"label":"C# - RestSharp","value":"csharp - RestSharp - C#"},{"label":"cURL - cURL","value":"curl - cURL - cURL"},{"label":"Dart - http","value":"dart - http - Dart"},{"label":"Go - Native","value":"go - Native - Go"},{"label":"HTTP - HTTP","value":"http - HTTP - HTTP"},{"label":"Java - OkHttp","value":"java - OkHttp - Java"},{"label":"Java - Unirest","value":"java - Unirest - Java"},{"label":"JavaScript - Fetch","value":"javascript - Fetch - JavaScript"},{"label":"JavaScript - jQuery","value":"javascript - jQuery - JavaScript"},{"label":"JavaScript - XHR","value":"javascript - XHR - JavaScript"},{"label":"C - libcurl","value":"c - libcurl - C"},{"label":"NodeJs - Axios","value":"nodejs - Axios - NodeJs"},{"label":"NodeJs - Native","value":"nodejs - Native - NodeJs"},{"label":"NodeJs - Request","value":"nodejs - Request - NodeJs"},{"label":"NodeJs - Unirest","value":"nodejs - Unirest - NodeJs"},{"label":"Objective-C - NSURLSession","value":"objective-c - NSURLSession - Objective-C"},{"label":"OCaml - Cohttp","value":"ocaml - Cohttp - OCaml"},{"label":"PHP - cURL","value":"php - cURL - PHP"},{"label":"PHP - Guzzle","value":"php - Guzzle - PHP"},{"label":"PHP - HTTP_Request2","value":"php - HTTP_Request2 - PHP"},{"label":"PHP - pecl_http","value":"php - pecl_http - PHP"},{"label":"PowerShell - RestMethod","value":"powershell - RestMethod - PowerShell"},{"label":"Python - http.client","value":"python - http.client - Python"},{"label":"Python - Requests","value":"python - Requests - Python"},{"label":"R - httr","value":"r - httr - R"},{"label":"R - RCurl","value":"r - RCurl - R"},{"label":"Ruby - Net::HTTP","value":"ruby - Net::HTTP - Ruby"},{"label":"Shell - Httpie","value":"shell - Httpie - Shell"},{"label":"Shell - wget","value":"shell - wget - Shell"},{"label":"Swift - URLSession","value":"swift - URLSession - Swift"}],"layoutOptions":[{"value":"classic-single-column","label":"Single Column"},{"value":"classic-double-column","label":"Double Column"}],"versionOptions":[],"environmentOptions":[{"value":"0","label":"No Environment"}],"canonicalUrl":"https://apidocs.stacs.io/view/metadata/UVyxRE45"}