@@ -417,7 +417,21 @@ Full example of `connections.json` and available parameters
417417 "tokenContractAddress": "0x3e672122bfd3d6548ee1cc4f1fa111174e8465fb",
418418 "migrateContractAddress": "0xa8ebf36b0a34acf98395bc5163103efc37621052",
419419 "customAbi": "abi.js"
420- }
420+ },
421+ "erc20Tokens": [
422+ {
423+ "name": "threshodl",
424+ "contractAddress": "0x3e672122bfd3d6548ee1cc4f1fa111174e8465fb"
425+ },
426+ {
427+ "name": "golem",
428+ "contractAddress": "0x9a0027f3c0fc4fab7825fcf50dd55dfdcca07cd6"
429+ },
430+ {
431+ "name": "bokky",
432+ "contractAddress": "0x583cbBb8a8443B38aBcC0c956beCe47340ea1367"
433+ }
434+ ]
421435 },
422436 "mainnet":{}
423437 }
@@ -433,7 +447,193 @@ transferOwnership & kill functions both catch an 'invalid address'. The response
433447`` subscription does not seem to work and or do
434448
435449
436- ## Endpoint Notes
450+ ## ERC20 Token Endpoint Notes
451+
452+ There is currently
453+
454+ ### Owner Contract
455+ This api is used for communications with the erc20 contract deployed within this repo and given in the ` connections.json ` :
456+
457+ ```
458+ "token": {
459+ "ownerAddress": "0x83634a8eaadc34b860b4553e0daf1fac1cb43b1e",
460+ "tokenContractAddress": "0x3e672122bfd3d6548ee1cc4f1fa111174e8465fb",
461+ ...
462+ },
463+ ```
464+
465+ The paths that can be used that are specific to this api are:
466+
467+ ```
468+ http://localhost:3000/api/token/:options
469+ /owner
470+ /node-accounts
471+ /balance
472+ /balance/:address
473+ /owner
474+ /add-tokens/:amount
475+ /transfer-tokens
476+ /transfer-owner
477+ /kill-token
478+ ```
479+
480+ ### ERC20 Multi-Token Endpoints Notes
481+
482+ This API supports multiple erc20 token connections. This means, you can communicate to different tokens by simple changing a path parameter in the url. See the instructions below Below you change the ` tokenName ` and ` erc20Method ` and
483+
484+ The paths that this api features are below:
485+ ```
486+ http://localhost:3000/api/token/:tokenName/:erc20Method
487+ /:tokenName
488+ /:tokenName/getbalance/:address
489+ /:tokenName/transfer
490+ /:tokenName/request-transfer
491+ ```
492+
493+ #### Setup
494+
495+ Add the ` erc20Tokens ` array parameter to the ` config/connections.json ` to add new tokens. Then add each new token as an object with a name and contractAddress parameter.
496+
497+ ```
498+ {
499+ "networks": {
500+ "connectApi": "ropsten",
501+ "ganache":{
502+ ...
503+ },
504+ "ropsten":{
505+ ...
506+ "token": {
507+ ...
508+ },
509+ "erc20Tokens": [
510+ {
511+ "name": "threshodl",
512+ "contractAddress": "0x3e672122bfd3d6548ee1cc4f1fa111174e8465fb"
513+ },
514+ {
515+ "name": "golem",
516+ "contractAddress": "0x9a0027f3c0fc4fab7825fcf50dd55dfdcca07cd6"
517+ },
518+ {
519+ "name": "bokky",
520+ "contractAddress": "0x583cbBb8a8443B38aBcC0c956beCe47340ea1367"
521+ }
522+ ]
523+ },
524+ "mainnet":{}
525+ }
526+ }
527+ ```
528+
529+ Then test is by adding it the name path param
530+
531+ Request (GET method):
532+ ```
533+ http://localhost:3000/api/token/threshodl
534+ ```
535+
536+ Response:
537+ ```
538+ {
539+ "method": "test",
540+ "params": {
541+ "tokenName": "threshodl"
542+ },
543+ "erc20Available": [
544+ {
545+ "name": "threshodl",
546+ "contractAddress": "0x3e672122bfd3d6548ee1cc4f1fa111174e8465fb"
547+ }
548+ ],
549+ "success": "Token threshodl is available on this api!"
550+ }
551+ ```
552+
553+ You can now use the rest of the api endpoints.
554+
555+ #### Get Balance
556+
557+ Get the balance for an address with the token selected.
558+
559+ ** Sample**
560+ Request (GET method):
561+ ```
562+ http://localhost:3000/api/token/threshodl/getbalance/0x07CE1F5852f222cc261ca803a1DA4a4016154539
563+ ```
564+
565+ Response:
566+
567+ ```
568+ {
569+ "method": "getbalance",
570+ "params": {
571+ "tokenName": "threshodl",
572+ "address": "0x83634a8eaadc34b860b4553e0daf1fac1cb43b1e"
573+ },
574+ "erc20Available": [
575+ {
576+ "name": "threshodl",
577+ "contractAddress": "0x3e672122bfd3d6548ee1cc4f1fa111174e8465fb"
578+ }
579+ ],
580+ "tokenBalance": "11300"
581+ }
582+ ```
583+
584+ #### Transfer
585+
586+ Transfer tokens between any two addresses.
587+
588+ Url:
589+ ```
590+ http://localhost:3000/api/token/threshodl/getbalance/0x07CE1F5852f222cc261ca803a1DA4a4016154539
591+ ```
592+
593+ Request:
594+ ```
595+ {
596+ "toAddress": "0x07CE1F5852f222cc261ca803a1DA4a4016154539",
597+ "value": 100,
598+ "gas": 41000,
599+ "privateKey": "0x7f74657374320000000000000000000000000000000000000000000000000057"
600+ }
601+ ```
602+
603+ Response:
604+ ```
605+ {
606+ "method": "transfer",
607+ "params": {
608+ "tokenName": "threshodl"
609+ },
610+ "body": {
611+ "toAddress": "0x07CE1F5852f222cc261ca803a1DA4a4016154539",
612+ "value": 100,
613+ "gas": 41000,
614+ "privateKey": "0xa6b7d3fb531567b199d025ded92cb86c685dba5247d4455041319bb0108985e7"
615+ },
616+ "erc20Available": [
617+ {
618+ "name": "threshodl",
619+ "contractAddress": "0x3e672122bfd3d6548ee1cc4f1fa111174e8465fb"
620+ }
621+ ],
622+ "transferABI": "0xa9059cbb00000000000000000000000007ce1f5852f222cc261ca803a1da4a40161545390000000000000000000000000000000000000000000000000000000000000064",
623+ "txSignature": {
624+ "messageHash": "0x28f36a05a927a8d245119baef7a0f0333e441dca6256601b42fba8c827b87b6b",
625+ "v": "0x2a",
626+ "r": "0xac47468f77fa1c862e66a28e76672e1a9586bca5074df3c2af8d0c53b9dfff36",
627+ "s": "0x1d8b87ff4d719103aff2a4384444a356f2d03bcbbeec6208acedfbcd0e6b569c",
628+ "rawTransaction": "0xf8a841843b9aca0082a028943e672122bfd3d6548ee1cc4f1fa111174e8465fb80b844a9059cbb00000000000000000000000007ce1f5852f222cc261ca803a1da4a401615453900000000000000000000000000000000000000000000000000000000000000642aa0ac47468f77fa1c862e66a28e76672e1a9586bca5074df3c2af8d0c53b9dfff36a01d8b87ff4d719103aff2a4384444a356f2d03bcbbeec6208acedfbcd0e6b569c"
629+ },
630+ "sendTxHash": {
631+ "txHash": "0x3d556ffdb7faa9577eec1251a84477d1ddaa5a12e64920d4f2bad2fc64d6cf9d"
632+ }
633+ }
634+ ```
635+
636+ ## Ethereum Endpoint Notes
437637
438638The ethereum endpoint for this API uses the [ web3js] ( http://web3js.readthedocs.io/en/1.0/ ) so parameters for a web3 method is normally supported by the endpoint unless otherwise specified.
439639
@@ -631,7 +831,6 @@ A websocket connection to the node is used to subscribe to events (e.g. new bloc
631831
632832You need to enable a websocket connection inside the node and add that url to the ` connections.json `
633833
634- ```
635834```
636835"ropsten":{
637836 ...
@@ -673,8 +872,17 @@ http://localhost:3000/api/eth/close-subscriptions/blockSubscription
673872http://localhost:3000/api/eth/close-subscriptions/syncingSubscription
674873```
675874
875+
676876## Endpoints
677877
878+ To get this endpoints run:
879+
880+ Request (GET method):
881+ ```
882+ http://localhost:3000/api-endpoints
883+ ```
884+
885+ Response:
678886```
679887[
680888 {
@@ -768,6 +976,36 @@ http://localhost:3000/api/eth/close-subscriptions/syncingSubscription
768976 "GET"
769977 ]
770978 },
979+ {
980+ "path": "/api/token/transfer-from",
981+ "methods": [
982+ "POST"
983+ ]
984+ },
985+ {
986+ "path": "/api/token/:tokenName",
987+ "methods": [
988+ "GET"
989+ ]
990+ },
991+ {
992+ "path": "/api/token/:tokenName/getbalance/:address",
993+ "methods": [
994+ "GET"
995+ ]
996+ },
997+ {
998+ "path": "/api/token/:tokenName/transfer",
999+ "methods": [
1000+ "POST"
1001+ ]
1002+ },
1003+ {
1004+ "path": "/api/token/:tokenName/request-transfer",
1005+ "methods": [
1006+ "POST"
1007+ ]
1008+ },
7711009 {
7721010 "path": "/api/eth",
7731011 "methods": [
0 commit comments