Exposes the bridge's HTTP web interface
4.1K
An API made for a Provable pTokens enclave built with Node using an express server.
Run the server via:
❍ node api-server
NOTE: To correctly populate the /peers route, provide the PEERS environment variable when starting the server, for example via:
❍ PEERS="nuc-bridge-1.ngrok.io/pbtc-on-eos" node api-server
./build-image vanilla <gpg-encrypted-gh-pat>
gpg-encrypted-gh-pat: GPG encrypted Github personal access token for local builds only.
When developing you can use:
./build-image vanilla <gpg-encrypted-gh-pat> -f Dockerfile.dev
It'll use the locally build version of ptokens-utils.js, so be sure to run the build-image script
from that repo first.
For on-the-fly testing you can also push the -dev suffixed image to the docker hub repo and pull
it wherever you need it.
1) Enter the directory:
❍ cd ptokens-api-server
2) Install dependencies:
❍ pnpm i
3) Run the tests:
❍ pnpx jest
1) Enter the directory:
❍ cd pBTC/enclave-api
2) Install dependencies:
❍ npm i
3) Run the linter
❍ npx eslint ./
Bear in mind:
node_) uses the endpoint http://<ptoken_node>/v1app_) uses the endpoint http://<ptoken_node>/pnative-on-host/v1node_pingcurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"node_ping", "params":[]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "pong"
}
node_peerscurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"node_peers", "params":[]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"webapi": "https://nuc-bridge-3.ngrok.io",
"info": {
"public_key": "020d308d2b70690483e5b950cf124f4346de240dd8358d096a426ba987aec6dba2",
"last_processed_host_block": 7943080,
"last_processed_native_block": 1746082,
"smart_contract_address": "eb770b1883dcce11781649e8c4f1ac5f4b40c978",
"host_symbol": "eth",
"native_symbol": "btc",
"host_network": "eth_ropsten",
"native_network": "btc_testnet"
},
"features": [
"pbtc-on-eth"
]
},
{
"webapi": "https://pbtc-node-1a.ngrok.io",
"info": {
"public_key": "0367663eeb293b978b495c20dee62cbfba551bf7e05a8381b374af84861ab6de39",
"last_processed_host_block": 10109073,
"last_processed_native_block": 631176,
"smart_contract_address": "5228a22e72ccc52d415ecfd199f99d0665e7733b",
"host_symbol": "eth",
"native_symbol": "btc",
"host_network": "eth_mainnet",
"native_network": "btc_mainnet"
},
"features": [
"pbtc-on-eth"
]
}
]
}
app_getInfocurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_getInfo", "params":[]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"host_symbol": "eth",
"host_network": "testnet_ropsten",
"native_symbol": "btc",
"native_network": "testnet",
"host_blockchain": "ethereum",
"native_blockchain": "bitcoin",
"last_processed_host_block": 7942709,
"last_processed_native_block": 1746050,
"smart_contract_address": "eb770b1883dcce11781649e8c4f1ac5f4b40c978",
"public_key": "020d308d2b70690483e5b950cf124f4346de240dd8358d096a426ba987aec6dba2"
}
}
app_queryReport[host, native] specify the type of report requestedNUMBER the noncecurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_queryReport", "params":["native", 3]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"_id": "pBTC_BTC 3",
"broadcast": true,
"broadcast_tx_hash": "852d0b2be71bdc8262bf2610f9160909a5247735c14d16040e9f85f4eddfc37d",
"broadcast_timestamp": 1588239526,
"native_tx_hash": "852d0b2be71bdc8262bf2610f9160909a5247735c14d16040e9f85f4eddfc37d",
"native_signed_tx": "010000000138ff2de1785e1e2659e898b6fc4ad9f4f9bea4c1c63266bcc2faacddd93c9264000000008f483045022100bc8de4412c436cceca578c8921b80abaf246d7993b2b4ae128945295463a4ee30220213ac4f48a31b4232e6a0a5a0ad92cda871b82886f4f904d9180a4cc6b9c0ba9014520dd30e089941e941c0ed870c032980ed1d6857964f7dde05d1f92391cb20916b27521020d308d2b70690483e5b950cf124f4346de240dd8358d096a426ba987aec6dba2acffffffff02f82a000000000000160014b5769134726407f86ee2c2b4c57a08b703822dabdefc0e00000000001976a91400d3444dc0582859a193c966c5bad743aad5dac688ac00000000",
"native_tx_amount": 11000,
"native_tx_recipient": "tb1qk4mfzdrjvsrlsmhzc26v27sgkupcytdt2mpwd8",
"native_account_nonce": 3,
"originating_tx_hash": "0x6abe28c8fe181c84f6751e373e7d11576f748654392def8d28fd66934b05df9b",
"originating_address": "0x831c10b32d14ae3d20e7316153abeb51cbd27e87",
"witnessed_timestamp": 1588239523,
"host_latest_block_number": 7815998
}
}
app_querySenderADDRESS native or host (filtering through originating_address field in mongodb)NUMBER upper limit of reports being returnedcurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_querySender", "params":["2N4g72pPnrBxTriwrmkKR8yzxyehMscLMnh", 3]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"_id": "pBTC_ETH 57",
"broadcast": true,
"broadcast_tx_hash": "0xa1f5a56924a1549cafcffc5698b60978e11389cc1def7f40805f1d054f6b537e",
"broadcast_timestamp": 1588615648,
"host_tx_hash": "0xa1f5a56924a1549cafcffc5698b60978e11389cc1def7f40805f1d054f6b537e",
"host_signed_tx": "f8aa398504a817c8008301d4c094eb770b1883dcce11781649e8c4f1ac5f4b40c97880b84440c10f19000000000000000000000000cabf3a4a81cbdb5e055322a85262a800bdf7a35f0000000000000000000000000000000000000000000000000003328b944c400029a0c96c9def9eaa62f2da3ea310b1cb90842d2567bdb7ced5f7ec91af826607d665a00ea0fc113127c1dd5ccbe181b159aed99cb00b7a02a6278c9d8c5f1f83afe1a2",
"host_tx_amount": "900000000000000",
"host_tx_recipient": "0xcabf3a4a81cbdb5e055322a85262a800bdf7a35f",
"host_account_nonce": 57,
"originating_tx_hash": "ee70694e46be24f9b6e5cb3cfe6293c7d2d12d90165683e8d9c6bd8fd0b0c347",
"originating_address": "2N4g72pPnrBxTriwrmkKR8yzxyehMscLMnh",
"witnessed_timestamp": 1588615642,
"native_latest_block_number": 1722924
}
]
}
app_queryRecipientADDRESS native or host (filtering through native_tx_recipient and native_tx_recipient fields)NUMBER upper limit of reports being returnedcurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_queryRecipient", "params":["tb1q3f2zmcs3ytsmr6msws9tgqq9zvknwz8zldk0zr", 4]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"_id": "pBTC_BTC 6",
"broadcast": true,
"broadcast_tx_hash": "2fba8ff2ef546cf530eae7fc2a5cf88053c8ae0be7daf7596e42d89ad1e963c7",
"broadcast_timestamp": 1588613369,
"native_tx_hash": "2fba8ff2ef546cf530eae7fc2a5cf88053c8ae0be7daf7596e42d89ad1e963c7",
"native_signed_tx": "010000000272d4601f6ebaac226e8bd49f1241b3eec307f5872c706d89028bdea679275702010000008f483045022100cd57022bce91591738913614c11f08998d0f5b3c202e9a26c047f9d520b1befe02204c359b1d225300eb06f34f08e35ddc9db8edc5cb8a731353516064f4e4a7c73a01452045ee66d2c19ecac8b678d455fc8a63d70b944a72d38432fafb01a71687f69a467521020d308d2b70690483e5b950cf124f4346de240dd8358d096a426ba987aec6dba2acffffffffacebd1b43645d6809ed38cad0cc29e3519e49ebbb4c533c10a19cbb817b8010b010000008e473044022071b04bb2e9acb7aa415779a227b2ad1fd6812cdf3da865b3e081053a82d56868022050ba6db3cb5d86d745000956cae3fae2f2b5442c42307d34896036b5974dd871014520cd68093d7078d902928b566aeda53e1a4d75731584c2286e95fe009ac9ba1e087521020d308d2b70690483e5b950cf124f4346de240dd8358d096a426ba987aec6dba2acffffffff0210270000000000001600148a542de21122e1b1eb70740ab40005132d3708e260110f00000000001976a91400d3444dc0582859a193c966c5bad743aad5dac688ac00000000",
"native_tx_amount": 10000,
"native_tx_recipient": "tb1q3f2zmcs3ytsmr6msws9tgqq9zvknwz8zldk0zr",
"native_account_nonce": 6,
"originating_tx_hash": "0xca0094d0e8301d3f725f14f1180830669f19e82b8caf024b9ac629e137ed7d1b",
"originating_address": "0x6a96b17601c59d867123c5f45c0867fc735ed15a",
"witnessed_timestamp": 1588613365,
"host_latest_block_number": 7843001
}
]
}
app_queryNativeAddressADDRESS native (filtering through originating_address field)NUMBER upper limit of reports being returnedcurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_queryNativeAddress", "params":["2N5PRKzf3wX8ZzbNNQa1JmF7QbmwtkkJLJw", 3]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"_id": "pBTC_ETH 37",
"broadcast": true,
"broadcast_tx_hash": "0x715b750ea6c030f7cc5af5180364c216a93af1caa3c3edaab190eeb6a99894d9",
"broadcast_timestamp": 1588533144,
"host_tx_hash": "0x715b750ea6c030f7cc5af5180364c216a93af1caa3c3edaab190eeb6a99894d9",
"host_signed_tx": "f8aa258504a817c8008301d4c094eb770b1883dcce11781649e8c4f1ac5f4b40c97880b84440c10f1900000000000000000000000022384a6aefc822db717f72f6bad8f60c919c7b4600000000000000000000000000000000000000000000000000038d7ea4c680002aa021a4ccd9ac5ad70cfd06a313d5b9e80ad79b06c72c49402a1464d6faa3ad01b2a03719b4632e49576ac70a6fef6fecd06181fb4adce706dd1aac8b8e6da660e6eb",
"host_tx_amount": "1000000000000000",
"host_tx_recipient": "0x22384a6aefc822db717f72f6bad8f60c919c7b46",
"host_account_nonce": 37,
"originating_tx_hash": "48a0b1aa08e76082527031b89ee0b1d203d0362c00837c466ea220c7bf51c137",
"originating_address": "2N5PRKzf3wX8ZzbNNQa1JmF7QbmwtkkJLJw",
"witnessed_timestamp": 1588513771,
"native_latest_block_number": 1722781
}
]
}
app_queryHostAddressADDRESS host (filtering through originating_address field)NUMBER upper limit of reports being returnedcurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_queryHostAddress", "params":["0x6a96b17601c59d867123c5f45c0867fc735ed15a", 3]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"_id": "pBTC_BTC 6",
"broadcast": true,
"broadcast_tx_hash": "2fba8ff2ef546cf530eae7fc2a5cf88053c8ae0be7daf7596e42d89ad1e963c7",
"broadcast_timestamp": 1588613369,
"native_tx_hash": "2fba8ff2ef546cf530eae7fc2a5cf88053c8ae0be7daf7596e42d89ad1e963c7",
"native_signed_tx": "010000000272d4601f6ebaac226e8bd49f1241b3eec307f5872c706d89028bdea679275702010000008f483045022100cd57022bce91591738913614c11f08998d0f5b3c202e9a26c047f9d520b1befe02204c359b1d225300eb06f34f08e35ddc9db8edc5cb8a731353516064f4e4a7c73a01452045ee66d2c19ecac8b678d455fc8a63d70b944a72d38432fafb01a71687f69a467521020d308d2b70690483e5b950cf124f4346de240dd8358d096a426ba987aec6dba2acffffffffacebd1b43645d6809ed38cad0cc29e3519e49ebbb4c533c10a19cbb817b8010b010000008e473044022071b04bb2e9acb7aa415779a227b2ad1fd6812cdf3da865b3e081053a82d56868022050ba6db3cb5d86d745000956cae3fae2f2b5442c42307d34896036b5974dd871014520cd68093d7078d902928b566aeda53e1a4d75731584c2286e95fe009ac9ba1e087521020d308d2b70690483e5b950cf124f4346de240dd8358d096a426ba987aec6dba2acffffffff0210270000000000001600148a542de21122e1b1eb70740ab40005132d3708e260110f00000000001976a91400d3444dc0582859a193c966c5bad743aad5dac688ac00000000",
"native_tx_amount": 10000,
"native_tx_recipient": "tb1q3f2zmcs3ytsmr6msws9tgqq9zvknwz8zldk0zr",
"native_account_nonce": 6,
"originating_tx_hash": "0xca0094d0e8301d3f725f14f1180830669f19e82b8caf024b9ac629e137ed7d1b",
"originating_address": "0x6a96b17601c59d867123c5f45c0867fc735ed15a",
"witnessed_timestamp": 1588613365,
"host_latest_block_number": 7843001
},
]
}
app_queryNativeReportsNUMBER upper limit of reports being returnedNUMBER page requested (results are paginated with a page size of 50 reports)curl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_queryNativeReports", "params":[3]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"_id": "pBTC_BTC 23",
"broadcast": true,
"broadcast_tx_hash": "9ab59ec7fcc64fb4e7862a847a276500e834d173a439c6dc4aa4fd02238462db",
"broadcast_timestamp": 1589924425,
"native_tx_hash": "9ab59ec7fcc64fb4e7862a847a276500e834d173a439c6dc4aa4fd02238462db",
"native_signed_tx": "0100000001bab8b5f2c8d3ea9e3949aedc1ba90ce89f322d955bfd7a35b83b5fdcb086c3a3010000008e4730440220275ee147a616717fdd9367e7b4e5172d40a95738be4440edecf44f3db37c274d02205838f36b560882c8e23bb8b35438dc73c050f5b962c570a810ad46153a0a1edb014520e3a447a2df7ee714a3c0711f9f6f3b2795d601629fe12c5db6736e8f11fd904c7521020d308d2b70690483e5b950cf124f4346de240dd8358d096a426ba987aec6dba2acffffffff02204e000000000000160014b74e8857fe6bff795a1c772f2a25c2d59ea369f0b6a40200000000001976a91400d3444dc0582859a193c966c5bad743aad5dac688ac00000000",
"native_tx_amount": 20000,
"native_tx_recipient": "tb1qka8gs4l7d0lhjksuwuhj5fwz6k02x60slua5z8",
"native_account_nonce": 23,
"originating_tx_hash": "0x310705fd79a097dde58350df7af8d1df9b98f3c6c24daba46abfacbd7e5bc9cc",
"originating_address": "0xa165841b556c54ad77f8e896a49cedcdff7ca4ac",
"witnessed_timestamp": 1589924420,
"host_latest_block_number": 7932419
},
]
}
app_queryHostReportsNUMBER upper limit of reports being returnedNUMBER page requested (results are paginated with a page size of 50 reports)curl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_queryHostReports", "params":[3]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"_id": "pBTC_ETH 118",
"broadcast": true,
"broadcast_tx_hash": "0x7bdbca6dcbafbc0045d80122c695d1e4cc366066923ecfd72e9ccc705877f153",
"broadcast_timestamp": 1590038672,
"host_tx_hash": "0x7bdbca6dcbafbc0045d80122c695d1e4cc366066923ecfd72e9ccc705877f153",
"host_signed_tx": "f8aa768504a817c8008301d4c094eb770b1883dcce11781649e8c4f1ac5f4b40c97880b84440c10f19000000000000000000000000c18abda7ca50736ee93f1f7ba712a4ee08649d1600000000000000000000000000000000000000000000000000005af3107a400029a0f40944709fa94c1a8cb8fa0e7e0b0739e0b3dc42f9b0dd04c8966aea044858c8a061f38d00e9d01691cb386558e9956210d080bdf1e9ad0306795ca4426e9d6d2c",
"host_tx_amount": "100000000000000",
"host_tx_recipient": "0xc18abda7ca50736ee93f1f7ba712a4ee08649d16",
"host_account_nonce": 118,
"originating_tx_hash": "2fcac6468cba8aab87df4048f33148f2c524afd814cdd46d9075766eb0044701",
"originating_address": "2N37Gi79fvoXZmXzLqZJhZVCNir2ApVq5KN",
"witnessed_timestamp": 1590038668,
"native_latest_block_number": 1746032
},
]
}
app_queryIncomingTxHashHASH of the incoming transaction (filtering through originating_tx_hash field)curl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_queryIncomingTxHash", "params":["b7994f840763b5ef7d942789fae8ff50ebf8b35a97357f5472f5c8798b1997aa"]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"_id": "pBTC_ETH 38",
"broadcast": true,
"broadcast_tx_hash": "0x3aa88350d1a39ed68bfa5b6d7850b76783140b78b3ac7804d5a0115d36b01115",
"broadcast_timestamp": 1588580917,
"host_tx_hash": "0x3aa88350d1a39ed68bfa5b6d7850b76783140b78b3ac7804d5a0115d36b01115",
"host_signed_tx": "f8aa268504a817c8008301d4c094eb770b1883dcce11781649e8c4f1ac5f4b40c97880b84440c10f19000000000000000000000000831c10b32d14ae3d20e7316153abeb51cbd27e87000000000000000000000000000000000000000000000000002386f26fc100002aa00373ea60df1f2aadb3b574e476f77ceed8ce49c720ab42562d731ca65df9a4a3a06cc7b516b58c218be8ed1260545e8d409b64cb03a64085771e19032d804df04b",
"host_tx_amount": "10000000000000000",
"host_tx_recipient": "0x831c10b32d14ae3d20e7316153abeb51cbd27e87",
"host_account_nonce": 38,
"originating_tx_hash": "b7994f840763b5ef7d942789fae8ff50ebf8b35a97357f5472f5c8798b1997aa",
"originating_address": "2MvGAxni9toiprqPDpDhxddLnSuC6oaYx83",
"witnessed_timestamp": 1588580912,
"native_latest_block_number": 1722877
}
}
app_queryBroadcastTxHashHASH of the broadcasting transaction (filtering through broadcast_tx_hash field)curl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_queryBroadcastTxHash", "params":["0x715b750ea6c030f7cc5af5180364c216a93af1caa3c3edaab190eeb6a99894d9"]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"_id": "pBTC_ETH 37",
"broadcast": true,
"broadcast_tx_hash": "0x715b750ea6c030f7cc5af5180364c216a93af1caa3c3edaab190eeb6a99894d9",
"broadcast_timestamp": 1588533144,
"host_tx_hash": "0x715b750ea6c030f7cc5af5180364c216a93af1caa3c3edaab190eeb6a99894d9",
"host_signed_tx": "f8aa258504a817c8008301d4c094eb770b1883dcce11781649e8c4f1ac5f4b40c97880b84440c10f1900000000000000000000000022384a6aefc822db717f72f6bad8f60c919c7b4600000000000000000000000000000000000000000000000000038d7ea4c680002aa021a4ccd9ac5ad70cfd06a313d5b9e80ad79b06c72c49402a1464d6faa3ad01b2a03719b4632e49576ac70a6fef6fecd06181fb4adce706dd1aac8b8e6da660e6eb",
"host_tx_amount": "1000000000000000",
"host_tx_recipient": "0x22384a6aefc822db717f72f6bad8f60c919c7b46",
"host_account_nonce": 37,
"originating_tx_hash": "48a0b1aa08e76082527031b89ee0b1d203d0362c00837c466ea220c7bf51c137",
"originating_address": "2N5PRKzf3wX8ZzbNNQa1JmF7QbmwtkkJLJw",
"witnessed_timestamp": 1588513771,
"native_latest_block_number": 1722781
}
}
app_getNativeDepositAddressADDRESS host address for which receive a native deposit addresscurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_getNativeDepositAddress", "params":["0x4b2AC8A5728E08CE71E64287DcbDa859D691Cf56"]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enclavePublicKey": "020d308d2b70690483e5b950cf124f4346de240dd8358d096a426ba987aec6dba2",
"nonce": 1590062779,
"nativeDepositAddress": "2N8RVgcErVkSZv24TweCpVwVTmnUr3oq2m2"
}
}
app_getDepositAddressArraycurl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_getDepositAddressArray", "params":[]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"nonce": 1584974727,
"eth_address": "0x8ebca32bd42d86ee51f762e968667e40b612b6f1",
"btc_deposit_address": "2NENMGYb5Uw4rJ6m5SnxbzQ2UaojNgA5p4Q",
"eth_address_and_nonce_hash": "0x3e127664d6d5206b20cd27ca7744f54eee43f6393164e3ebfd6fec976d5681d1"
},
{
"nonce": 1584977139,
"eth_address": "0x8ebca32bd42d86ee51f762e968667e40b612b6f1",
"btc_deposit_address": "2NEKNDzPpm7fotYLWRtym2KDRtZ1EhTxv88",
"eth_address_and_nonce_hash": "0x23cc534f8f696fbb2e46e62dd30870b3a68566100259b6991db1d1af5b371f1c"
},
]
}
curl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_getLastProcessedHostBlock", "params":[]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": 7967050
}
curl -sS -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0", "id":1, "method":"app_getLastProcessedNativeBlock", "params":[]}'
{
"jsonrpc": "2.0",
"id": 1,
"result": 7967050
}
Content type
Image
Digest
sha256:5b7f8989c…
Size
162.5 MB
Last updated
over 3 years ago
docker pull provable/ptokens-api-server:4.6.5-vanilla