HTTP API for Server Side Environment

Recall from the section Before You Begin, the following setup.

alt text

In this section we present the HTTP REST API and responses over Webhook. Intended audience is a Java developer wanting the NodeJS abstrated by simple HTTP APIs.

We present each api endpoint with params and responses.

Note that each HTTP API is a GET and respond with status code 201. All responses are in JSON and are sent to Java over webhook url: /webhook.

Ensure before running the Node Server, the .env file should include the following environment variables. For example:

PKS="9038d1a01a3c1d34840f0a49ab1fb54b29e48f659a749df260db3ea432d77ebf"
HTTP="http://localhost:8545"
WS="ws://localhost:8545"
WEBHOOK="http://localhost:8000/webhook"
HTTP_PORT=9090

PKS is a comma separated string of all your Trust Anchor accounts private keys (note 0x removed).

HTTP is the RPC IP and Port of the TestNet.

WS is the Websocket IP and Port of the TestNet.

WEBHOOK is the url for the Java environment in this example.

HTTP_PORT is the port of this node server.

Note: http-api-js next section is the full node js file referenced below.

API

create trust anchor account

url: /ta-create-account
request: GET
params: nil

response:

{
request: 'ta-create-account'
address: '0x68c1a65E3456b6cEc5561156E2430921144E15ef',
privateKey: '0x9038d1a01a3c1d34840f0a49ab1fb54b29e48f659a749df260db3ea432d77ebf',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
}

is trust anchor account verified

url: /is-ta-verified?account=0x68c1a65E3456b6cEc5561156E2430921144E15ef
request: GET
params:
account: 0x68c1a65E3456b6cEc5561156E2430921144E15ef

response:

{
request: 'is-ta-verified',
result: true,
account: '0x68c1a65E3456b6cEc5561156E2430921144E15ef'
}

get balance

url: /get-balance?account=0x68c1a65E3456b6cEc5561156E2430921144E15ef
request: GET
params:
account: 0x68c1a65E3456b6cEc5561156E2430921144E15ef
(note balance in WEI)

response:

{
request: 'get-balance',
balance: '10000000000000000000',
account: '0x68c1a65E3456b6cEc5561156E2430921144E15ef'
}

trust anchor set unique address

url: /ta-set-unique-address?account=0x68c1a65E3456b6cEc5561156E2430921144E15ef
request: GET
params:
account: 0x68c1a65E3456b6cEc5561156E2430921144E15ef

response:

{
request: 'ta-set-unique-address',
result: BN {
negative: 0,
words: [ 1, <1 empty item> ],
length: 1,
red: null
},
account: '0x68c1a65E3456b6cEc5561156E2430921144E15ef'
}
{
request: 'ta-set-unique-address',
hash: {
tx: '0xeafa1d82be139d8418440b67e909c33693a581dca73b7507e76f2071b467ef22',
receipt: {
transactionHash: '0xeafa1d82be139d8418440b67e909c33693a581dca73b7507e76f2071b467ef22',
transactionIndex: 0,
blockHash: '0xd216cc8da74e8227a5b672af291657101c61d8264c93e72a2ade071fd45d4298',
blockNumber: 543,
from: '0x68c1a65e3456b6cec5561156e2430921144e15ef',
to: '0x284e91d6047ba49737154a45ebc3fba5ebf4e17f',
gasUsed: 45580,
cumulativeGasUsed: 45580,
contractAddress: null,
logs: [Array],
status: true,
logsBloom: '0x00000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000002000000000000000000',
rawLogs: [Array]
},
logs: [ [Object] ]
},
account: '0x68c1a65E3456b6cEc5561156E2430921144E15ef'
}

trust anchor set key value pair

url: /ta-set-key-value-pair?account=0x68c1a65E3456b6cEc5561156E2430921144E15ef&key_name=ENTITY&key_value=ACME INC.
request: GET
params:
account: 0x68c1a65E3456b6cEc5561156E2430921144E15ef
key_name: ENTITY
key_value: ACME INC.

response:

{
request: 'ta-set-key-value-pair',
result: BN {
negative: 0,
words: [ 1, <1 empty item> ],
length: 1,
red: null
},
account: '0x68c1a65E3456b6cEc5561156E2430921144E15ef'
}
{
request: 'ta-set-key-value-pair',
hash: {
tx: '0xbcf9668bf653e39f12c132da53fa819a6227dcb4901199d14adbe6addf78dcf6',
receipt: {
transactionHash: '0xbcf9668bf653e39f12c132da53fa819a6227dcb4901199d14adbe6addf78dcf6',
transactionIndex: 0,
blockHash: '0x180ba3bbd71afc6695df8673893d87cb890da9b9a206f58cf044e0ec2981d743',
blockNumber: 544,
from: '0x68c1a65e3456b6cec5561156e2430921144e15ef',
to: '0xc37f608ff7b0edb779c0660de912f12ce0bbc864',
gasUsed: 157213,
cumulativeGasUsed: 157213,
contractAddress: null,
logs: [Array],
status: true,
logsBloom: '0x00000000000000000000000000000000000000000020000010000000000000000000000000000000000000008002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000001000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
rawLogs: [Array]
},
logs: [ [Object] ]
},
account: '0x68c1a65E3456b6cEc5561156E2430921144E15ef'
}

trust anchor set endpoint

url: /ta-set-endpoint?account=0x68c1a65E3456b6cEc5561156E2430921144E15ef&endpoint_name=acme.com&ip_address=127.0.0.1
request: GET
params:
account: 0x68c1a65E3456b6cEc5561156E2430921144E15ef
key_name: acme.com
key_value: "127.0.0.1"

response:

{
request: 'ta-set-endpoint',
result: BN {
negative: 0,
words: [ 1, <1 empty item> ],
length: 1,
red: null
},
account: '0x68c1a65E3456b6cEc5561156E2430921144E15ef'
}
{
request: 'ta-set-endpoint',
hash: {
tx: '0xec2cf8cee06da82fc0dabb96ea5773b70651a0419b6854c1db627c64a83440f8',
receipt: {
transactionHash: '0xec2cf8cee06da82fc0dabb96ea5773b70651a0419b6854c1db627c64a83440f8',
transactionIndex: 0,
blockHash: '0x0aa1107196b870929cd03b48dbdc3ad5fb0f44aaf6cc204faaf31152239be077',
blockNumber: 545,
from: '0x68c1a65e3456b6cec5561156e2430921144e15ef',
to: '0xcea2c0c5f2c05d88a497a85fc7999125233661a5',
gasUsed: 136423,
cumulativeGasUsed: 136423,
contractAddress: null,
logs: [Array],
status: true,
logsBloom: '0x00000000000000000000000000000000000000000020008000000000000000000000000000000000000000000002000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
rawLogs: [Array]
},
logs: [ [Object] ]
},
account: '0x68c1a65E3456b6cEc5561156E2430921144E15ef'
}

trust anchor create user account

url: /ta-create-user-account?user_id=1
request: GET
params: user_id
note user_id is the id of your user in your exchange

response:

{
address: '0x98f23e2E65f32d45b1F4D6e65259A980670872b4',
privateKey: '0x62458e1701f29ac59e1d86aeb8f4084dc0aea0f682bd8df4addd83f8cb88deb4',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt],
user_id: '1'
}

trust anchor set attestation

url: /ta-set-attestation?user_account=0x98f23e2E65f32d45b1F4D6e65259A980670872b4&jurisdiction=1&effective_time=1564449732&expiry_time=1627694532&public_data=WALLET&documents_matrix_encrypted=16Qygw3QgX4TgZxneVWQeVVxp2XNYf9vP9&availability_address_encrypted=BTC&is_managed=true&ta_account=0x68c1a65E3456b6cEc5561156E2430921144E15ef
request: GET
params:
user_account: 0x98f23e2E65f32d45b1F4D6e65259A980670872b4
jurisdiction: INT
effective_time: UNIX TIMESTAMP
expiry_time: UNIX TIMESTAMP
public_data: "WALLET"
documents_matrix_encrypted: "16Qygw3QgX4TgZxneVWQeVVxp2XNYf9vP9"
availability_address_encrypted: "BTC"
is_managed: true
ta_account: 0x68c1a65E3456b6cEc5561156E2430921144E15ef

response:

{
request: 'ta-set-attestation',
result: Result {
'0': BN { negative: 0, words: [Array], length: 1, red: null },
'1': '0x380800f183bd8c803976f14230c8a3521db9f5631efc865238577f2954d745eb',
result: BN { negative: 0, words: [Array], length: 1, red: null },
resultAttestationKeccak: '0x380800f183bd8c803976f14230c8a3521db9f5631efc865238577f2954d745eb'
}
}
{
request: 'ta-set-attestation',
hash: {
tx: '0x8068d2017b5b9f6fcb53c758b5a8f7c4eabde96f753cbd8b194c6ceba398799e',
receipt: {
transactionHash: '0x8068d2017b5b9f6fcb53c758b5a8f7c4eabde96f753cbd8b194c6ceba398799e',
transactionIndex: 0,
blockHash: '0x9076a2e235720cceef48da52cb9e4efebefcceb567efb32ae1e20622e23bac9e',
blockNumber: 546,
from: '0x68c1a65e3456b6cec5561156e2430921144e15ef',
to: '0x5b7f41346df7636b52a3b227019f62affaa5c3de',
gasUsed: 506590,
cumulativeGasUsed: 506590,
contractAddress: null,
logs: [Array],
status: true,
logsBloom: '0x00000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000008010000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
rawLogs: [Array]
},
logs: [ [Object] ]
}
}

trust anchor get attestation array for trust anchor account

url: /ta-get-attestation-array-for-ta-account?account=0x68c1a65E3456b6cEc5561156E2430921144E15ef
request: GET
params:
account: 0x68c1a65E3456b6cEc5561156E2430921144E15ef

response:

{
request: 'ta-get-attestation-array-for-ta-account',
result: [
'0x380800f183bd8c803976f14230c8a3521db9f5631efc865238577f2954d745eb'
]
}

trust anchor get attestation array for user account

url: /ta-get-attestation-array-for-user-account?account=0x98f23e2E65f32d45b1F4D6e65259A980670872b4
request: GET
params:
account: 0x98f23e2E65f32d45b1F4D6e65259A980670872b4

response:

{
request: 'ta-get-attestation-array-for-user-account',
result: [
'0x380800f183bd8c803976f14230c8a3521db9f5631efc865238577f2954d745eb'
]
}

trust anchor get attestation components

url: /ta-get-attestation-components?account=0x380800f183bd8c803976f14230c8a3521db9f5631efc865238577f2954d745eb
request: GET
params:
attestation_hash: 0x380800f183bd8c803976f14230c8a3521db9f5631efc865238577f2954d745eb

response:

{
request: 'ta-get-attestation-components',
result: Result {
'0': '0x68c1a65E3456b6cEc5561156E2430921144E15ef',
'1': BN { negative: 0, words: [Array], length: 1, red: null },
'2': BN { negative: 0, words: [Array], length: 2, red: null },
'3': BN { negative: 0, words: [Array], length: 2, red: null },
'4': '0x57414c4c4554',
'5': '0x37383963363336306330306231343161663063623133303234633034653431333038633866373536326239353534313661343261353932393339393561366135613531363239653932386135323439363234326135393435396235386561393839616538353831386561313831613031623138316231386561313231353063343130326330326534353935386538393831616539353839383830333939363036343035353430366330386334303634303235363633613136653631303835313038653139353464613438633764343030613464336463343263376332313232383062653439623033383538313363303332303262623631363862303330316336313032303637',
'6': '0x4254430000000000000000000000000000000000000000000000000000000000',
'7': true,
trustAnchorAddress: '0x68c1a65E3456b6cEc5561156E2430921144E15ef',
jurisdiction: BN { negative: 0, words: [Array], length: 1, red: null },
effectiveTime: BN { negative: 0, words: [Array], length: 2, red: null },
expiryTime: BN { negative: 0, words: [Array], length: 2, red: null },
publicData: 'WALLET',
documentsMatrixEncrypted: '16Qygw3QgX4TgZxneVWQeVVxp2XNYf9vP9',
availabilityAddressEncrypted: 'BTC',
isManaged: true
}
}

KYC Template Helper Functions

get kyc template (JSON)

url: /kyc-get-template
request: GET
params: nil

response:

{
"AttestationHash": "",
"BeneficiaryTAAddress": "",
"BeneficiaryTAPublicKey": "",
"BeneficiaryTASignatureHash": "",
"BeneficiaryTASignature": {},
"BeneficiaryUserAddress": "",
"BeneficiaryUserPublicKey": "",
"BeneficiaryUserSignatureHash": "",
"BeneficiaryUserSignature": {},
"CryptoAddressType": "",
"CryptoAddress": "",
"CryptoPublicKey": "",
"CryptoSignatureHash": "",
"CryptoSignature": {},
"SenderTAAddress": "",
"SenderTAPublicKey": "",
"SenderTASignatureHash": "",
"SenderTASignature": {},
"SenderUserAddress": "",
"SenderUserPublicKey": "",
"SenderUserSignatureHash": "",
"SenderUserSignature": {},
"BeneficiaryKYC": "",
"SenderKYC": ""
}

get ETH address from public key

url: /kyc-get-eth-address-from-public-key
request: POST
params: {"public_key": string}
eg:
{
"public_key": "8870c2e326b9b7ad0fad7c58475e5d29867debaf0f8a0de7d6a24266c258a3e9d70977250325bf15bcbddaa3c5d8f320a7b93ad99801cd9b64c6f841f1be87f1"
}

response:

{
"address": "0xdA67F7EB772f709b626469ec9055d081f451C118"
}

get eth public key from private key

url: /kyc-get-eth-public-key
request: GET
params: private_key
eg: /kyc-get-eth-public-key?private_key=fba556045b439f709efc0abecb8bcf7bdd661b2186fbbdfd4db157aa451936f5

response:

{
"publicKey": "8870c2e326b9b7ad0fad7c58475e5d29867debaf0f8a0de7d6a24266c258a3e9d70977250325bf15bcbddaa3c5d8f320a7b93ad99801cd9b64c6f841f1be87f1"
}

encrypt data with public key

url: /kyc-encrypt-data
request: POST
params: {"public_key": string, "data": json}
eg:
{
"public_key": "8870c2e326b9b7ad0fad7c58475e5d29867debaf0f8a0de7d6a24266c258a3e9d70977250325bf15bcbddaa3c5d8f320a7b93ad99801cd9b64c6f841f1be87f1",
"data":{"fullname": "John Smith", "dob":"1990-01-30", "jurisdiction": "SG"}
}

response:

{
"kycEncryptData": "zWF72XKgSXfOAXxjjG9d/gSD9zIIRY2/qFL+aVc3b2OiktpSG3OJwO/wSuyeEtmG0rJ63LnKncdliE93dFlPByhIFsYDQM7vXR+oa3vCU3EzH8LUxIgK2GwFdiM4y9tI7h9uwo+DSAy3GYG8RuLWaCJoUgrv9b0xeyvYxwbUhAxf9c9yUHnXrdbTCZ5ec4NZ8GDmC9uBvO1A40rQF+n2Vio+kiSFGIhY6QCfXqKI2mJLt/FbajPLQw1EYT55sLprLg=="
}

decrypt data with private key

url: /kyc-decrypt-data
request: POST
params: {"private_key": string, "data": string}
eg:
{
"private_key": "fba556045b439f709efc0abecb8bcf7bdd661b2186fbbdfd4db157aa451936f5",
"data":"zWF72XKgSXfOAXxjjG9d/gSD9zIIRY2/qFL+aVc3b2OiktpSG3OJwO/wSuyeEtmG0rJ63LnKncdliE93dFlPByhIFsYDQM7vXR+oa3vCU3EzH8LUxIgK2GwFdiM4y9tI7h9uwo+DSAy3GYG8RuLWaCJoUgrv9b0xeyvYxwbUhAxf9c9yUHnXrdbTCZ5ec4NZ8GDmC9uBvO1A40rQF+n2Vio+kiSFGIhY6QCfXqKI2mJLt/FbajPLQw1EYT55sLprLg=="
}

response:

{
"fullname": "John Smith",
"dob": "1990-01-30",
"jurisdiction": "SG"
}

get signature and hash

url: /kyc-get-signature-and-hash
request: POST
params: {"signature_message": string, "private_key": string}
eg:
{
"signature_message": "ACME VASP",
"private_key": "0xfba556045b439f709efc0abecb8bcf7bdd661b2186fbbdfd4db157aa451936f5"
}

response:

{
"SignatureHash": "0x6d22b5cb8615f6dd22982cce1c76fedcdc7e314a36ce6b50413a60024f10c19b",
"Signature": {
"r": "0xa4cd6e6cbe7f87320f73e6703b5c764051309d0c6948e924fba8bf0ac83a76f6",
"s": "0x4f14f966803eb0ba7cb8800e734719dc300d13f8478660ed5ac6646b94e6fdb4",
"v": "0x26"
}
}

recover public key from signature and signature hash

url: /kyc-recover-public-key-from-signature-and-hash
request: POST
params: {"signature_hash": string, "signature": json}
eg:
{
"signature_hash": "0x6d22b5cb8615f6dd22982cce1c76fedcdc7e314a36ce6b50413a60024f10c19b",
"signature": {
"r": "0xa4cd6e6cbe7f87320f73e6703b5c764051309d0c6948e924fba8bf0ac83a76f6",
"s": "0x4f14f966803eb0ba7cb8800e734719dc300d13f8478660ed5ac6646b94e6fdb4",
"v": "0x26"
}
}

response:

{
"publicKey": "8870c2e326b9b7ad0fad7c58475e5d29867debaf0f8a0de7d6a24266c258a3e9d70977250325bf15bcbddaa3c5d8f320a7b93ad99801cd9b64c6f841f1be87f1"
}