Introduction
Welcome to the official documentation SmartHoldem API! You can use our API to access SmartHoldem API endpoints Node-A.
We have language bindings in Shell, HTTP! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
connect to the mainnet api, use the link to node: http://127.0.0.1:6100/api/
parameter | type | request | mainnet |
---|---|---|---|
nethash | string | header | fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
port | integer | header | 6100 |
connect to the devnet api, use the link to node: http://80.211.38.83:6101/api/
parameter | type | request | devnet |
---|---|---|---|
nethash | string | header | 3a6d2bec6798dedea99a1e6c64120a3876781b85e46bb75908aba07ffda61360 |
port | integer | header | 6101 |
addr version | integer | - | 30 |
slip 44 | integer | - | 1 |
Accounts
Get the balance of an account
curl -k -X GET "http://127.0.0.1:6100/api/accounts/getBalance?address={address}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/accounts/getBalance?address={address} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success": true,
"balance": "45848090000000",
"unconfirmedBalance": "45848090000000"
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/accounts/getBalance?address={address}
Query Parameters
Parameter | Type | Description |
---|---|---|
address | string (query) |
SmartHoldem Address |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the public key of an account
curl -k -X GET "http://127.0.0.1:6100/api/accounts/getPublickey?address={address}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/accounts/getPublickey?address={address} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success": true,
"publicKey": "030751d7c998d7f6c901bd78fb1516413d05f1384121af9b69ff6eb3a76f7107e9"
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/accounts/getPublickey?address={address}
Query Parameters
Parameter | Type | Description |
---|---|---|
address | string (query) |
SmartHoldem Address |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the delegate fee of an account
curl -k -X GET "http://127.0.0.1:6100/api/accounts/delegates/fee"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/accounts/delegates/fee HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success": true,
"fee": "5500000000"
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/accounts/delegates/fee
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the delegates of an account
curl -k -X GET "http://127.0.0.1:6100/api/accounts/delegates?address={address}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/accounts/delegates?address={address} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success": true,
"delegates": [
{
"username":"bitshill",
"address":"SPvhZpt4qEYHLrUDqeHhu1H1qtmkK3xovH",
"publicKey":"030751d7c998d7f6c901bd78fb1516413d05f1384121af9b69ff6eb3a76f7107e9",
"vote":"45848090000000",
"producedblocks":1466,
"missedblocks":2172,
"rate":71,
"approval":0.19,
"productivity":0
}
]
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/accounts/delegates?address={address}
Query Parameters
Parameter | Type | Description |
---|---|---|
address | string (query) |
SmartHoldem Address |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Returns account information of an address
curl -k -X GET "http://127.0.0.1:6100/api/accounts?address={address}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/accounts?address={address} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"account":
{
"address":"SPvhZpt4qEYHLrUDqeHhu1H1qtmkK3xovH",
"unconfirmedBalance":"45848090000000",
"balance":"45848090000000",
"publicKey":"030751d7c998d7f6c901bd78fb1516413d05f1384121af9b69ff6eb3a76f7107e9",
"unconfirmedSignature":0,
"secondSignature":0,
"secondPublicKey":null,
"multisignatures":[],
"u_multisignatures":[]
}
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/accounts?address={address}
Query Parameters
Parameter | Type | Description |
---|---|---|
address | string (query) |
SmartHoldem Address |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get a list of top accounts
curl -k -X GET "http://127.0.0.1:6100/api/accounts/top?limit={limit}&offset={offset}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/accounts/top?limit={limit}&offset={offset} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"accounts":[
{
"address":"SUeGCt31AHwTZVcfZQwpPVL4jEUCtMMDTg",
"balance":"1440865700000000",
"publicKey":"02babe75fc3f053e041f2258b11727c81b21bb690e69f2ea99b3121223b7536e56"
},
{
"address":"STwo9GdFTNeCJZkbQYuqBRnN1jgPqsKrr6",
"balance":"800001000000000",
"publicKey":null
},
{
"address":"SMTku8XXxSDcnYxvWsfX5D2AMZwVjdrBe6",
"balance":"720000000000000",
"publicKey":null
}
]
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/accounts/top?limit={limit}&offset={offset}
Query Parameters
Parameter | Type | Description |
---|---|---|
limit | integer (query) |
An unsigned integer that specifies the maximum number of records. |
offset | integer (query) |
An unsigned integer that specified the number of records to skip. |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Blocks
Get block by id
curl -k -X GET "http://127.0.0.1:6100/api/blocks/get?id={blockid}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks/get?id={blockid} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"block":
{
"id":"17539280775357750950",
"version":0,
"timestamp":9068960,
"height":833616,
"previousBlock":"16727550229762671827",
"numberOfTransactions":1,
"totalAmount":17000000000,
"totalFee":10000000,
"reward":200000000,
"payloadLength":32,
"payloadHash":"d2db523d5f904f06e264a6cd07ae7eb3d910de3d8513f78c322ff62e889ead0f",
"generatorPublicKey":"0352323bcc05b7eb8f67d30cf6c68c31f55fdb1ae502089ec53be7bd6066aa0cc3",
"generatorId":"SekmmTz5t31QsRuiiQYxtBmhaZ3sTRJqTR",
"blockSignature":"304402204fa031c043edf8b9eda482447424f515079e91f0babb6750804fc0fcea5ae60e022010b1d869b9cbe439035c381ff21366cc92bc36156c2f09a50c2eacb3122ca14c",
"confirmations":1469,
"totalForged":"210000000"
}
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/blocks/get?id={blockid}
Query Parameters
Parameter | Type | Description |
---|---|---|
id | string (query) |
SmartHoldem block id |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get all blocks
curl -k -X GET "http://127.0.0.1:6100/api/blocks?limit={limit}&orderBy={orderByFieldName}&offset={offset}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks?limit={limit}&orderBy={orderByFieldName}&offset={offset} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"blocks":
[
{
"id":"9116970896546202944",
"version":0,
"timestamp":0,
"height":1,
"previousBlock":null,
"numberOfTransactions":468,
"totalAmount":24000000000000000,
"totalFee":0,"reward":0,
"payloadLength":98905,
"payloadHash":"fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7",
"generatorPublicKey":"03b2000d0e5042e82aed1fe7d7b556ba7cbc921406fe65cc3881652115f843fbb9",
"generatorId":"SVx2j3NdZbDLfZ9HWS57NvqYg4c9grQLnx",
"blockSignature":"30450221008f8426d8777668ed54147227577f86757d754e66872b9f1afd0b408431e4e2fc02200fed52f899e793beebefcea5d261ef04ef178ae5148ce74c33bee3cc6290daf7",
"confirmations":835148,
"totalForged":"0"
},
{
"id":"16196929714027847359",
"version":0,
"timestamp":2018712,
"height":2,
"previousBlock":"9116970896546202944",
"numberOfTransactions":2,
"totalAmount":100000000,
"totalFee":5510000000,
"reward":0,
"payloadLength":64,
"payloadHash":"d10891c597ab873a024b6d3204c77919bc0c1cfc71637c8c280f2984719002ff",
"generatorPublicKey":"024fb81d61afe6dec253236a210822f1c5fb93ee2f944751df5d0c4b1d0fb29059",
"generatorId":"Sea51MNodyxQRdGGWpTpHj38ZnrKrDFaHk",
"blockSignature":"3044022076254a6bd3e6b6c49c07309253000b8dc0ca0f0a6cd9e6b876f53ec685f274ee0220336400f106111a66932fa922867bc28d3c66fdf29bb65c93cf661be0d7278e7d",
"confirmations":835147,
"totalForged":"5510000000"
}
],
"count":835148
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/blocks?limit={limit}&orderBy={orderByFieldName}&offset={offset}
Query Parameters
Parameter | Type | Description |
---|---|---|
limit | integer (query) |
An unsigned integer that specifies the maximum number of records. |
orderBy | string (query) |
A string that specifies the column by which to sort the records. |
offset | integer (query) |
An unsigned integer that specified the number of records to skip. |
generatorPublicKey | string (query) |
A valid Public Key. |
totalAmount | integer (query) |
amount |
totalFee | integer (query) |
fee |
reward | integer (query) |
reward |
previousBlock | string (query) |
|
height | integer (query) |
height |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the BlockChain Epoch
curl -k -X GET "http://127.0.0.1:6100/api/blocks/getEpoch"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks/getEpoch HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"epoch":"2017-11-21T13:00:00.000Z"
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/blocks/getEpoch
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the BlockChain Height
curl -k -X GET "http://127.0.0.1:6100/api/blocks/getHeight"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks/getHeight HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"height":835227,
"id":"13808010658243907328"
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/blocks/getHeight
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the BlockChain NetHash
curl -k -X GET "http://127.0.0.1:6100/api/blocks/getNethash"
-H "accept: application/json"
GET api/blocks/getHeight HTTP/1.1
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"nethash":"fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
}
]
Return JSON.
HTTP Request
GET http://127.0.0.1:6100/api/blocks/getNethash
Query Parameters
Parameter | Type | Description |
---|---|---|
port | integer (header) |
6100 |
Get the Transaction Fee
curl -k -X GET "http://127.0.0.1:6100/api/blocks/getFee"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks/getFee HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"fee":10000000
}
]
Get the transaction fee for sending "normal" transactions.
HTTP Request
GET http://127.0.0.1:6100/api/blocks/getFee
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the Network Fees
curl -k -X GET "http://127.0.0.1:6100/api/blocks/getFees"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks/getFees HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"fees":
{
"send":10000000,
"vote":100000000,
"secondsignature":500000000,
"delegate":5500000000,
"multisignature":500000000
}
}
]
Get the all fees network.
HTTP Request
GET http://127.0.0.1:6100/api/blocks/getFees
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the BlockChain Milestone
curl -k -X GET "http://127.0.0.1:6100/api/blocks/getMilestone"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks/getMilestone HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"milestone":0
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/blocks/getMilestone
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the BlockChain Reward
curl -k -X GET "http://127.0.0.1:6100/api/blocks/getReward"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks/getReward HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"reward":200000000
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/blocks/getReward
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the BlockChain Supply
curl -k -X GET "http://127.0.0.1:6100/api/blocks/getSupply"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks/getSupply HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"supply":24167148400000000
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/blocks/getSupply
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the BlockChain Status
curl -k -X GET "http://127.0.0.1:6100/api/blocks/getStatus"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
GET api/blocks/getStatus HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"epoch":"2017-11-21T13:00:00.000Z",
"height":835759,"fee":10000000,
"milestone":0,
"nethash":"fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7",
"reward":200000000,
"supply":24167151800000000
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/blocks/getStatus
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Transactions
Send Transaction
curl -k -H "Content-Type: application/json" -X PUT
-d '{"secret":"<AddressSecretPassphrase>","amount":<Amount>,"recipientId":"<RecipientAddress>"}'
http://127.0.0.1:6100/api/transactions
PUT api/transactions HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
{
"secret": "one two the four five six seven eith night ten eleven twelwe",
"amount": 100000000,
"recipientId": "SiGek5KGRWzGaRxb87CeukeeBhvi1Uu57b"
}
The above command returns JSON structured like this:
[
{
"success":true,
"transactionId":"cace8c8bfe47541c4d587ede2acd2a05ce0a79c25877b98d219d363643e051a7"
}
]
JSON Response
HTTP Request
PUT http://127.0.0.1:6100/api/transactions
Query Parameters
Parameter | Type | Description |
---|---|---|
secret | string (query) |
one two the four five six seven eith night ten eleven twelwe |
amount | integer (query) |
amount in satoshi (100000000 = 1 COIN) |
recipientId | string (query) |
Recipient Address |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get a single transaction
curl -X GET "http://127.0.0.1:6100/api/transactions/get?id={TxID}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/transactions/get?id={TxID} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"transaction":
{
"id":"6de0bf336fb0b232e27cc79822d5c69e8604c9c4ac1e55099c8403243e5c6e6f",
"blockid":"17539280775357750950",
"height":833616,
"type":0,
"timestamp":9068949,
"amount":17000000000,
"fee":10000000,
"senderId":"Sf6y6bFqdPiXt9qupmTdpJFJwBWmMCfs43",
"recipientId":"SZg73u3rVrqwahfZ2tU6G1E3YwDs52tMeW",
"senderPublicKey":"03e340952f7d726d8598b4ae68e88e583b39735c35b489559e082c705dba50376e",
"signature":"30450221009f5617a4f68deb466ef26c6aa5165f32ea7db23c77882d455b6a6d7fa6ad6e5e02205cf900ea86ef0bc4d5102e3d4292984c949453f6e5da756321ad8c61a3786ec7",
"asset":{},
"confirmations":2919
}
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/transactions/get?id={TxID}
Query Parameters
Parameter | Type | Description |
---|---|---|
id | string (query) |
A valid transaction ID |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get all transactions
curl -X GET "http://127.0.0.1:6100/api/transactions?limit={limit}&offset={offset}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/transactions?limit={limit}&offset={offset} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"transactions":
[
{
"id":"2bf77bdb8a97f6b8bb8e9b656a57e8971f49ff93f494c2ba420dd8fc35e1a34a",
"blockid":"16602765030304240142",
"type":0,
"timestamp":2465122,
"amount":61042030621,
"fee":10000000,
"senderId":"SVx2j3NdZbDLfZ9HWS57NvqYg4c9grQLnx",
"recipientId":"SSkYDCEXYxkETPRNHzRPAr2CgEVwq3sRtH",
"senderPublicKey":"03b2000d0e5042e82aed1fe7d7b556ba7cbc921406fe65cc3881652115f843fbb9",
"signature":"304402205fa2532675d2f3043f4a727c3be0f510b9dab361b05a7bb0838fedcdb5a8d817022006f84a20bb17c209c01f46ba0ed4b4becb90fb0c28da9e937f9da00dee7f78e7",
"asset":{},
"confirmations":792507
},
{
"id":"f98257d351549ccf4956aa3abb04304db8970924a4880e97c1ecd389edd0346b",
"blockid":"1749022156066192207",
"type":0,
"timestamp":2465174,
"amount":743602918474,
"fee":10000000,
"senderId":"SVx2j3NdZbDLfZ9HWS57NvqYg4c9grQLnx",
"recipientId":"SYWCs4KM8DtfUoxVkNnyetja91P2b7mSvg",
"senderPublicKey":"03b2000d0e5042e82aed1fe7d7b556ba7cbc921406fe65cc3881652115f843fbb9",
"signature":"304402201b16338c61e935e12112b14f7493531ec1d9a4ed73806447bd182797911d10e40220742972459a4b6701bbc26a8fe1817b930f0d2df54fbc83b36c422c40a3c91636",
"asset":{},
"confirmations":792503
}
],
"count":"6411"
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/transactions?limit={limit}&offset={offset}
Query Parameters
Parameter | Type | Description |
---|---|---|
blockId | string (query) |
An unsigned integer that specifies the block ID. |
limit | integer (query) |
An unsigned integer that specifies the maximum number of records. |
offset | integer (query) |
An unsigned integer that specified the number of records to skip. |
type | integer (query) |
An unsigned integer that specifies the transaction type. |
orderBy | string (query) |
A string that specifies the column by which to sort the records. |
senderPublicKey | string (query) |
A valid Public Key. |
ownerPublicKey | string (query) |
A valid Public Key. |
ownerAddress | string (query) |
A valid Address. |
senderId | string (query) |
A valid Address. |
recipientId | string (query) |
A valid Address. |
amount | integer (query) |
An unsigned integer that specifies the transaction amount. |
fee | integer (query) |
An unsigned integer that specifies the transaction fee. |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get all unconfirmed transactions
curl -X GET "http://127.0.0.1:6100/api/transactions/unconfirmed"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/transactions/unconfirmed HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"transactions":[]
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/transactions/unconfirmed
Query Parameters
Parameter | Type | Description |
---|---|---|
senderPublicKey | string (query) |
A valid Public Key. |
address | string (query) |
A valid Address. |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Timestamp Calc TX
Calculation of transaction time begins from the first block 11/21/2017 @ 1:00pm (UTC), from unix time: 1511269200
To get a human transaction time it is necessary to add to 1511269200 timestamp specified in the transaction
Example:
tx result:
{
"success": true,
"transaction": {
"id": "2f5f333d46e6de3b77e76be0a358f83fb25cb4c3c8907fce117acef7f74c6844",
"blockid": "15218540347764387952",
"height": 135452,
"type": 0,
"timestamp": 3354199,
"amount": 200000000000,
"fee": 10000000,
"senderId": "STHiQuGcpz8EQstJiBZ5HkVWxrSwc7wPgH",
"recipientId": "SVx2j3NdZbDLfZ9HWS57NvqYg4c9grQLnx",
"senderPublicKey": "02573f491df3c6f031660b4b64b0421103fe32ec3d8615a234892aba227191aab5",
"signature": "3044022025303c28855f97b75e92d878dd5ff8023549da81b7605986e3bbf3ca57957d760220756e0d87be2aab86e27c6cd145ae45ba7edf2a51151cc35e98765f59b711c536",
"asset": {
},
"confirmations": 2985891
}
}
tx timestamp = 3354199
human time = 1511269200 + 3354199 = 1514623399 = 12/30/2017 @ 8:43am (UTC)
Delegate
Get the count of delegates
curl -X GET "http://127.0.0.1:6100/api/delegates/count"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/delegates/count HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"count":234
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/delegates/count
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Search for specific delegates
curl -X GET "http://127.0.0.1:6100/api/delegates/search?q={DelegateName}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/delegates/search?q={DelegateName} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"delegates":
[
{
"username":"davinchi",
"address":"SRSDXgqkDpkdvfLWymW4GkXfqqhDydDpKn",
"publicKey":"02be233e7d9e46407cdcdc5793a792b52f399cab61ccd8eb256a32a6cd06b5b7d3",
"vote":"274851156039575",
"producedblocks":13026,
"missedblocks":58
}
]
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/delegates/search?q={DelegateName}
Query Parameters
Parameter | Type | Description |
---|---|---|
q | string (query) |
A search query |
limit | integer (query) |
An unsigned integer that specifies the maximum number of records |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get a list of voters for a delegate
curl -X GET "http://127.0.0.1:6100/api/delegates/voters?publicKey={publicKey}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/delegates/voters?publicKey={publicKey} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"accounts":
[
{
"username":"gendelegate_8",
"address":"Sgx3VdXJyKGdNrtLP6J569zuWrevqA4qc1",
"publicKey":"02202a328734a92dda73673e8d163cd33a1047b05ca3c83508011883557f4c843e",
"balance":"16498890000000"
},
{
"username":null,
"address":"SRsTDAb5UvxpubvhR4xN4PBP3zsAjn88wH",
"publicKey":"03b04b6afc16b57923021d3f3eb89dc4efc8d7e975a1ecbfbeaca40ea4d61485b4",
"balance":"2631764374584"
}
]
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/delegates/voters?publicKey={publicKey}
Query Parameters
Parameter | Type | Description |
---|---|---|
publicKey | string (query) |
A valid Public Key |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get a single delegate
curl -X GET "http://127.0.0.1:6100/api/delegates/get?publicKey={publicKey}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/delegates/get?publicKey={publicKey} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"delegate":
{
"username":"tomray",
"address":"SMNwAWtVnkPjYrLG9wgtpwRG3nwxVQpL3x",
"publicKey":"0393dbe9e234b98b66c517b8ebff2b8c6649dd2fab9c33dd14616c4551458e6dff",
"vote":"228633454374584",
"producedblocks":10314,
"missedblocks":237,
"rate":4,
"approval":0.95,
"productivity":97.75
}
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/delegates/get?publicKey={publicKey}
Query Parameters
Parameter | Type | Description |
---|---|---|
publicKey | string (query) |
A valid Public Key |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get all delegates
curl -X GET "http://127.0.0.1:6100/api/delegates?limit={limit}&offset={offset}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/delegates?limit={limit}&offset={offset} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"delegates":
[
{
"username":"terra",
"address":"SkLRQb6cFPdCpVDNLyQKtwUeUtwH3Mm5yf",
"publicKey":"0364b75b76624a97776bccc602e4a21864ac2f792b097841a2f6e2495d994b463b",
"vote":"120074817218230",
"producedblocks":6389,
"missedblocks":333,
"rate":65,
"approval":0.5,
"productivity":0
},
{
"username":"old_susanin",
"address":"SkK3c5UfZoa2T9fTM2iEw81HxqS7EisrTm",
"publicKey":"027a4f588f2ebd3498fb94e3b468139b9ab4a4cc9a0044dfe5ac8bc3c2f48a909f",
"vote":"113259700000000",
"producedblocks":1058,
"missedblocks":360,
"rate":66,
"approval":0.47,
"productivity":0
}
],
"totalCount":234
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/delegates?limit={limit}&offset={offset}
Query Parameters
Parameter | Type | Description |
---|---|---|
orderBy | string (query) |
A string that specifies the column by which to sort the records. |
limit | integer (query) |
An unsigned integer that specifies the maximum number of records. |
offset | integer (query) |
An unsigned integer that specified the number of records to skip. |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the delegate fee
curl -X GET "http://127.0.0.1:6100/api/delegates/fee"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/delegates/fee HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"fee":5500000000
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/delegates/fee
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the amount of forged by an account
curl -X GET "http://127.0.0.1:6100/api/delegates/forging/getForgedByAccount?generatorPublicKey={generatorPublicKey}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/delegates/forging/getForgedByAccount?generatorPublicKey={generatorPublicKey} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"fees":"0",
"rewards":"211600000000",
"forged":"211600000000"
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/delegates/forging/getForgedByAccount?generatorPublicKey={generatorPublicKey}
Query Parameters
Parameter | Type | Description |
---|---|---|
generatorPublicKey | string (query) |
A valid public key. |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the next forger
curl -X GET "http://127.0.0.1:6100/api/delegates/getNextForgers?address={address}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/delegates/getNextForgers?address={address} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"currentBlock":836047,
"currentSlot":1136180,
"delegates":
[
"03efb6fa51dcf652dbf1f6a7d5102628517264d3d39cfa4c61e75a631637cfbc92",
"0388a6b44c7188baaa31514a5decb8e5e9ce4ebef9ca47d72bf6b361aca5a38be8",
"02bcc5e31c334e04e05e02ea1f119b168306af1699a939c1829cf5b9a2e3a7703e",
"020b271151f8fe73951ebf9acadf569790a16a744e7b7640e204ff76907b92b541",
"035946968bf3c0be80d788c030601b840fb10afa2de81ea90516e4db21b106a244",
"02a38631617efc1d81cbea978bee3158f7232a1b9f50e06ed96410071f372afab3",
"03d059624fbc0379db4c93c276b83eccbc48acabe9896aa3c47f165efd36080db3",
"025af9eb82e8842330f5e1a3df832c49272531912b5ca45fc445bd49236a9d30e5",
"03e878e58677d9a0391707a24014564c36af50518610ff3b4d54b300153d35a0db",
"02c5ccbc6f2f56460fc274ba604ba819ab6c4b5a9ff6d89f4a24013b61a994c510"
]
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/delegates/getNextForgers?address={address}
Query Parameters
Parameter | Type | Description |
---|---|---|
address | string (query) |
A valid Address |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Loader
Get the BlockChain Status Load
curl -X GET "http://127.0.0.1:6100/api/loader/status"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/loader/status HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"loaded":false,
"now":836088,
"blocksCount":0
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/loader/status
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the synchronisation status of the client
curl -X GET "http://127.0.0.1:6100/api/loader/status/sync"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/loader/status/sync HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"syncing":false,
"blocks":1,
"height":836128,
"id":"11305115970511710322"
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/loader/status/sync
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Auto-configure the client loader
curl -X GET "http://127.0.0.1:6100/api/loader/autoconfigure"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/loader/autoconfigure HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"network":
{
"nethash":"fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7",
"token":"STH",
"symbol":"STH",
"explorer":"https://blockexplorer.smartholdem.io",
"version":63
}
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/loader/autoconfigure
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Peers
Get a single peer
curl -X GET "http://127.0.0.1:6100/api/peers/get?ip={IP}&port={Port}"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/peers/get?ip={IP}&port={Port} HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"peer":
{
"ip":"215.130.200.190",
"port":6100,
"version":"0.0.2",
"errors":0,
"os":"linux4.13.0-26-generic",
"height":836660,
"status":"OK",
"delay":37
}
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/peers/get?ip={IP}&port={Port}
Query Parameters
Parameter | Type | Description |
---|---|---|
ip | string (query) |
A valid server IP |
port | integer (query) |
A valid server Port |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get all peers
curl -X GET "http://127.0.0.1:6100/api/peers"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/peers HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"peer":
{
"ip":"215.130.200.190",
"port":6100,
"version":"0.0.2",
"errors":0,
"os":"linux4.13.0-26-generic",
"height":836660,
"status":"OK",
"delay":37
}
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/peers
Query Parameters
Parameter | Type | Description |
---|---|---|
state | integer (query) |
An unsigned integer that specifies the peer state. |
port | integer (query) |
A valid peer Port |
os | integer (query) |
A valid operating system |
version | string (query) |
A valid node version |
limit | integer (query) |
An unsigned integer that specifies the maximum number of records |
offset | integer (query) |
An unsigned integer that specified the number of records to skip |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the peer version
curl -X GET "http://127.0.0.1:6100/api/peers/version"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET api/peers/version HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"version":"0.0.2",
"build":""
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/api/peers/version
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Transport
Operations for Transports
Get a list of peers
curl -X GET "http://127.0.0.1:6100/peer/list"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET /peer/list HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"version":"0.0.2",
"build":""
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/peer/list
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get a list of blocks by ids
curl -X GET "http://127.0.0.1:6100/peer/blocks/common?ids='{id}'"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET /peer/blocks/common?ids='{id}' HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"common":
{
"height":837951,
"id":"14680647590392835738",
"previousBlock":"3557000320223856005",
"timestamp":9105256
},
"lastBlockHeight":837978
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/peer/blocks/common?ids='{id}'
Query Parameters
Parameter | Type | Description |
---|---|---|
ids | string (query) |
ids - list of block IDs |
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the status
curl -X GET "http://127.0.0.1:6100/peer/status"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET /peer/status HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"height":838130,
"forgingAllowed":false,
"currentSlot":1138339,
"header":
{
"id":"3559432260321673957",
"height":838130,
"version":0,
"totalAmount":0,
"totalFee":0,
"reward":200000000,
"payloadHash":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"payloadLength":0,
"timestamp":9106712,
"numberOfTransactions":0,
"previousBlock":"5309083107160493676",
"generatorPublicKey":"02d0c97cc201c752b53718ff36ff48ca5dead557bc1c47335476e71a0143263789",
"blockSignature":"3045022100b65d13e3ad465af4b7eb3209e25ccc62d7df74f2f1ea50b97ec973e8981f074402203d1af020a5cf744fdb41f2472ef30ebfaf5c0367adcc994db92895a9f272e14a"
}
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/peer/status
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Get the blockchain height peer
curl -X GET "http://127.0.0.1:6100/peer/height"
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
GET /peer/height HTTP/1.1
nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7
host: 127.0.0.1:6100
The above command returns JSON structured like this:
[
{
"success":true,
"height":838152,
"header":
{
"id":"1745814126765338549",
"height":838152,
"version":0,
"totalAmount":0,
"totalFee":0,
"reward":200000000,
"payloadHash":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"payloadLength":0,
"timestamp":9106896,
"numberOfTransactions":0,
"previousBlock":"15643855646433486272",
"generatorPublicKey":"033691a3abe70be86360d312c4b173d48e0a94fc34c10517e95dae711549533755",
"blockSignature":"3045022100dc956f488ff066529dd064acaa89fb5454ffa08bc92ebd24744780cc69581d9d02204444c98c1368e0c2ae765a126ed27068bbe4b09026d61e22b25054e98fd98b05"
}
}
]
JSON Response
HTTP Request
GET http://127.0.0.1:6100/peer/height
Query Parameters
Parameter | Type | Description |
---|---|---|
nethash | string (header) |
fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7 |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Broadcast a new transaction
curl -X POST "http://127.0.0.1:6100/peer/transactions"
-d '{"transactions":[<A valid transactions object>]}'
-H "accept: application/json"
-H "nethash: fc46bfaf9379121dd6b09f5014595c7b7bd52a0a6d57c5aff790b42a73c76da7"
-H "version: 0.0.2"
-H "port: 6100"
The above command returns JSON structured like this:
[
{
"success":true,
"transaction":
{
"type":0,
"amount":10000000,
"fee":10000000,
"recipientId":"Sa9JKodiNeM7tbYjxwEhvvG1kBczhQxTN3",
"timestamp":9165933,
"asset":{},
"senderPublicKey":"03675c61dcc23eab75f9948c6510b54d34fced4a73d3c9f2132c76a29750e7a614",
"signature":"304402201342810cdd2db452aff3b4c6367101a6973f40d7d4601647a8433c7bc547bde902202629f5fae8405097147edb8e10839d58dc56f1f154dfe3db3a3dcfd7acf4bdb9",
"id":"477c43012b1720de6f924918ad1ee7e41fc74ef5ed30ed628ea3af877ad203f1"
}
}
]
JSON Response
HTTP Request
POST http://127.0.0.1:6100/peer/transactions
Query Parameters
Parameter | Type | Description |
---|---|---|
transactions | string (header) |
A valid transaction object |
version | string (header) |
0.0.2 |
port | integer (header) |
6100 |
Examples
Receive Tx Method 1
Receive Transactions with a message
This guide discusses the method of accepting payments with a note to the payment (message) in the SmartHoldem ecosystem. The service uses 1 address, but for each user a unique string is generated.
For simplicity of understanding, PHP is used as a backend.
In the process involved: the service (exchanger) and the user (the client).
Benefits:
- 1 address is sufficient for accepting payments
- simple integration
- convenient control of funds
- processing of a large number of transactions
Client
From the client side, a certain service-exchanger, generates the initial data for the client:
- the amount to be received in the exchangeable coin (specified by the client)
- calculated result to be received at the current exchange rate STH> COIN
- address for sending STH (for all users one)
- a unique message string (identifies the sender)
Here on the service side in backend a unique string is generated for each user and stored in a database, for example, a table of the form: userid (int), msg (string)
<?php
// example generate unique user string
$msg = substr(md5(uniqid(microtime(), 1)) . getmypid(), 1, 8);
// result unique string: 561559b2
The client, knowing the initial data, sends the corresponding amount with a note to the specified address with the help of his wallet.
Service
Now the backend of the service, the transaction handler, enters the work. For ease of understanding, we will use the execution of the script on crontab.
We create a php-file on the server side, then we'll assign it to cron every minute.
<?php
$addr = 'Sg13BhANeairfS3o3w8N9sKaFrsht2bt4V'; //transaction verification service address
$limit = 25; //transaction limit
$offset = 0;
//sort out the issuance of transactions by timestamp using orderBy
$url = 'http://your_node_ip:6100/api/transactions?recipientId='.$addr.'&orderBy=timestamp&offset=0';
//get the data and convert it to an array
$tx = json_decode(file_get_contents($url),true);
/*
if the transaction is more than a limit,
offset transaction transfer pointer and get the last $ limit of transactions,
since transactions can be hundreds of thousands
*/
if ($tx['count'] > $limit) {
$offset = $tx['count'] - $limit; // calculation of displacement
$url = 'http://node_ip:6100/api/transactions?recipientId=Sg13BhANeairfS3o3w8N9sKaFrsht2bt4V&orderBy=timestamp&offset='.$offset;
$tx = json_decode(file_get_contents($url),true);
}
// processing data
for ($i = 0; $i < count($tx['transactions']); $i++) {
print "<br>amount:".$tx['transactions'][$i]['amount'].
" timestamp:".$tx['transactions'][$i]['timestamp'].
" msg:".$tx['transactions'][$i]['vendorField'].
" senderId:".$tx['transactions'][$i]['senderId'].
" Txid:".$tx['transactions'][$i]['id'];
/*
here we perform the necessary checks and writes to the database,
for example, add a balance
To save in the transaction table unique transactions,
which are also checked upon receipt,
for example txid, userid, timestamp, sum_sth, sum_coin
*/
/*
remember, the balance is issued in satoshi,
do not forget to convert it to exact functions
*/
$sumCOIN = bcdiv($tx['transactions'][$i]['amount'],100000000,8);
$set['btc_sth'] = 1; //course in relation to STH
$sumBTC = bcdiv($sumCOIN, $set['btc_sth'], 8); //calculate the coin rate
}
Congratulations, the transaction is processed, the operation is completed.
Send Tx PHP
A simple PHP example of sending transactions.
<?php
$url = 'http://node_ip:6100/api/transactions';
$data = json_encode((object) array(
"secret" => "sender address secret pass phrase",
"amount" => 10000000, //0.1 STH in Satoshi
"recipientId" => "Sa9JKodiNeM7tbYjxwEhvvG1kBczhQxTN3", //recipient address
"vendorField" => "any message" // optional
));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true); //convert to array
print_r($result); //show result
JS API Wrapper 0.1.6
https://github.com/smartholdem/sthjs-wrapper
https://www.npmjs.com/package/sthjs-wrapper
Installation
npm install --save sthjs-wrapper
# install
npm install --save sthjs-wrapper
Initialization
Before you begin, choose a network to initialize a list of nodes in that network
// init
var smartholdemApi = require("sthjs-wrapper");
var network = "main" //or "dev"
smartholdemApi.init(network);
-- JS Accounts --
Account related API calls.
Get balance
Get the balance of an account.
Request
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getBalance("Address of the account", (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"balance": Balance of account (Integer String),
"unconfirmedBalance": "Unconfirmed balance of account (Integer String)"
}
Get account public key
Get the public key of an account. If the account does not exist the API call will return an error.
Request
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getPublicKey("Address of the account", (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"publicKey": "Public key of account. (Hex String)"
}
Get account
Returns account information of an address.
Request
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getAccount("Address of the account", (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"account": {
"address": "Address of account. (String)",
"unconfirmedBalance": "Unconfirmed balance of account. (String)",
"balance": "Balance of account. (String)",
"publicKey": "Public key of account. (Hex String)",
"unconfirmedSignature": "If account enabled second signature, but it's still not confirmed. (0 or 1)",
"secondSignature": "If account enabled second signature. (0 or 1)",
"secondPublicKey": "Second signature public key. (Hex String)"
}
}
Get votes of account
Get votes by account address.
Request
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getVotes("Address of the account", (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"delegates": [
{
username: Delegate Name (String),
address: Delegate Address (String),
publicKey: Delegate public key (String),
vote: Number of votes (Integer String),
producedBlocks: Number of Blocks Produces (Integer),
missedBlocks: Number of missed blocks (Integer),
rate: Delegate rank (Integer)
approval: Percent approval (float)
productivity: Percent blocks forged (float)
}
...
]
}
-- JS Blocks --
Blocks manage API.
Get block
Get block by id.
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getBlock("id: Id of block", (err, success, response) => {
console.log(response);
});
Response
{
"success": true,
"block": {
"id": "Id of block. (String)",
"version": "Version of block. (Integer)",
"timestamp": "Timestamp of block. (Integer)",
"height": "Height of block. (Integer)",
"previousBlock": "Previous block id. (String)",
"numberOfTransactions": "Number of transactions. (Integer)",
"totalAmount": "Total amount of block. (Integer)",
"totalFee": "Total fee of block. (Integer)",
"payloadLength": "Payload length of block. (Integer)",
"payloadHash": "Payload hash. (Hex String)",
"generatorPublicKey": "Generator public key. (Hex String)",
"generatorId": "Generator id. (String)",
"blockSignature": "Block signature. (Hex)"
}
}
Get blocks
Get all blocks.
var smartholdemApi = require("sthjs-wrapper")
var parameters = {
"totalFee: total fee of block. (Integer)",
"totalAmount: total amount of block. (Integer)",
"previousBlock: previous block of need block. (String)",
"height: height of block. (Integer)",
"generatorPublicKey: generator id of block in hex. (String)",
"limit: limit of blocks to add to response. Default to 20. (Integer)",
"offset: offset to load blocks. (Integer)",
"orderBy: field name to order by. Format: fieldname:orderType. Example: height:desc, timestamp:asc (String)"
};
smartholdemApi.getBlocks(parameters, (error, success, response) => {
console.log(response);
});
All parameters joins by OR.
Response
{ "success": true, "blocks": [ "array of blocks" ] }
Get blockchain fee
Get transaction fee for sending "normal" transactions.
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getBlockchainFee((error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"fee": "fee amount"
}
Get blockchain height
Get blockchain height.
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getBlockchainHeight((error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"height": Height of blockchain. (Integer)
}
Get forged by account
Get amount forged by account.
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getForgedByAccount("Delegate public key (String)",
(error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"sum": Forged amount (Integer)
}
-- JS Delegates --
Delegates API.
Enable delegate on account
Calls for delegates
Get delegate
Get delegate by username.
Request
var smartholdemApi = require("sthjs-wrapper");
smartholdemApi.getDelegate("username of delegate", (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"delegate": {
username: Delegate Name (String),
address: Delegate Address (String),
publicKey: Delegate public key (String),
vote: Number of votes (Integer String),
producedBlocks: Number of Blocks Produces (Integer),
missedBlocks: Number of missed blocks (Integer),
rate: Delegate rank (Integer)
approval: Percent approval (float)
productivity: Percent blocks forged (float)
}
}
Get delegates
Get delegates list.
Request
var smartholdemApi = require("sthjs-wrapper");
var parameters = {
"limit: Limit to show. Integer. (Integer)",
"offset: Offset (Integer)",
"orderBy: Order by field (String)"
};
smartholdemApi.getDelegates(parameters, (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"delegates": [Array of delegate objects]
}
Get Next Forgers
Get delegates next in line to forge
Request
var smartholdemApi = require("sthjs-wrapper");
smartholdemApi.getNextForgers((error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"currentBlock": Current block height (Integer),
"currentSlot": Current slot (integer),
"delegates": [Array of delegate public keys in order of forging]
}
Get votes of account
Get votes by account address.
Request
var smartholdemApi = require("sthjs-wrapper");
smartholdemApi.getVotes("Address of the account. (String)", (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"delegates": [array of delegates]
}
Get voters
Get voters of delegate.
Request
var smartholdemApi = require("sthjs-wrapper");
smartholdemApi.getVoters("Public key of delegate. (String)", (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"accounts": [array of accounts who voted for delegate]
}
-- JS Peers --
Peers API.
Get peers list
Get peers list by parameters.
Request
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getPeersList((error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"peers": [
{
ip: IP Address (String),
port: Port number (Integer),
version: Node version (String),
errors: Errors (Integer),
os: Operating System (String),
height: Block height (Integer),
status: Node status (String),
delay: Ping (Integer)
}
...
]
}
Get peer
Get peer by ip and port
Request
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getPeer("ip: Ip of peer. (String)",
"port: Port of peer. (Integer)",
(error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"peer": {peer object}
}
Get peer version, build time
Get peer version and build time
Request
var smartholdemApi = require("sthjs-wrapper")
smartholdemApi.getPeerVersion((error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"version": "version of SmartHoldem Peer",
"build": "time of build"
}
-- JS Transactions --
API calls related to transactions
Create Transaction
Creates a transaction object to be sent.
Example
var smartholdemApi = require("sthjs-wrapper");
var options = {
vendorField: "Message field (optional 64 bytes)",
secondPassphrase: "Sender second passphrase (optional)"
};
var transaction = smartholdemApi.createTransaction("Sender passphrase",
"Address of recipient",
"Amount to send in 10^8 (Integer)",
options);
console.log(transaction);
Create Delegate Transaction
Creates a delegate registration transaction to be sent
Example
var smartholdemApi = require("sthjs-wrapper");
var transaction = smartholdemApi.createDelegateTransaction("Passphrase",
"Delegate name",
"Second passphrase (optional)");
console.log(transaction);
Create Second Signature Transaction
Creates a second signature transaction to be sent
Example
var smartholdemApi = require("sthjs-wrapper");
var transaction = smartholdemApi.createSecondSignatureTransaction("Passphrase",
"Second passphrase");
console.log(transaction);
Create Vote Transaction
Creates a vote transaction to be sent
Example
var smartholdemApi = require("sthjs-wrapper");
var transaction = smartholdemApi.createVoteTransaction("Passphrase",
["+58199578191950019299181920120128129"] //Array of vote strings
"Second passphrase");
console.log(transaction);
Send transactions
Broadcasts an array of transactions to multiple nodes
Example
var smartholdemApi = require("sthjs-wrapper");
var transaction = smartholdemApi.sendTransactions([Transactions array], (error, success, response) => {
console.log(response);
});
Response
{
success: true,
transactionIds: [
"ID of transaction that was sent (String)",
"ID of transaction that was sent (String)",
"ID of transaction that was sent (String)",
...
]
}
Get list of transactions
Transactions list matched by provided parameters.
Request
var smartholdemApi = require("sthjs-wrapper");
var parameters = {
"blockId": "Block id of transaction. (String)",
"senderId": "Sender address of transaction. (String)",
"recipientId": "Recipient of transaction. (String)",
"limit": "Limit of transaction to send in response. Default: 20. Max: 50 (Integer number)",
"offset": "Offset to load. (Integer number)",
"orderBy": "Name of column to order. After column name must go 'desc' or 'asc' to choose order type. Example: orderBy=timestamp:desc (String)"
};
smartholdemApi.getTransactionsList(parameters, (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"transactions": [
{
id: Transaction ID (String),
blockid: Block ID (Integer String),
type: Transaction type (Integer),
timestamp: Seconds since genesis block (Integer),
amount: Transaction amount (Integer)
fee: Transaction fee (Integer),
venderField: Vender field/Smartbridge (String),
senderId: Sender address (String),
recipientId: Recipient address (String),
senderPublicKey: Sender public key (String),
signature: Transaction signature (String),
asset: Asset (Object),
confirmations: Number of confirmations (Integer)
}
count: Number of results (String)
]
}
Get transaction
Transaction matched by id.
Request
var smartholdemApi = require("sthjs-wrapper");
smartholdemApi.getTransaction("String of transaction (String)", (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"transaction": {Transaction Object}
}
Get unconfirmed transaction
Get unconfirmed transaction by id.
Request
var smartholdemApi = require("sthjs-wrapper");
smartholdemApi.getUnconfirmedTransaction("String of transaction (String)", (error, success, response) => {
console.log(response);
});
Response
{
"success": true,
"transaction": {Transaction Object}
}
Get list of unconfirmed transactions
Get list of unconfirmed transactions.
Request
var smartholdemApi = require("sthjs-wrapper");
smartholdemApi.getUnconfirmedTransactions((error, success, response) => {
console.log(response);
});
Response
{
"success" : true,
"transactions" : [list of transaction objects]
}
RPC Daemon
How To Use It
All calls should be made from the server where RPC is running at ( i.e., localhost or 127.0.0.1 ).
The RPC server should never be publicly accessible.
If you wish to access smartholdem-rpc from a remote address, you can whitelist the address with --allow <address>
.
Addresses allow you to use wildcards, eg. 192.168.1.* or 10.0.*.*.
If you do want to allow access from all remotes, start smartholdem-rpc with the --allow-remote
commandline switch. This can be dangerous.
This is an additional library. Works as a bitcoind.
git clone https://github.com/smartholdem/smartholdem-rpc.git
cd smartholdem-rpc
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh 2>/dev/null | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm install 6.9.5 >>install.log
nvm use 6.9.5 >>install.log
nvm alias default 6.9.5
npm install -g npm
npm install forever -g
npm install grunt-cli -g
npm install
forever start server.js
- install Node.JS
- install forever npm install -g forever
- git clone https://github.com/smartholdem/smartholdem-rpc.git
- install smartholdem-rpc: npm install
- start RPC server: forever start server.js
- stop RPC server: forever stop server.js
default port 8282
Get account balance from address
curl -X GET "http://127.0.0.1:8282/mainnet/account/{address}"
-H "accept: application/json"
RESPONSE Get account balance from address
[
{
"success":true,
"account":
{
"address":"SUeGCt31AHwTZVcfZQwpPVL4jEUCtMMDTg",
"unconfirmedBalance":"1440865700000000",
"balance":"1440865700000000",
"publicKey":"02babe75fc3f053e041f2258b11727c81b21bb690e69f2ea99b3121223b7536e56",
"unconfirmedSignature":0,
"secondSignature":0,
"secondPublicKey":null,
"multisignatures":[],
"u_multisignatures":[]
}
}
]
GET http://127.0.0.1:8282/mainnet/account/{address}
Create account from Pass Phrase
curl -X POST "http://127.0.0.1:8282/mainnet/account"
-d '{"passphrase":"TestPassWord"}'
-H "Content-Type: application/json"
RESPONSE Create account from Pass Phrase
[
{
"success":true,
"account":
{
"publicKey":"02f83b9419d8edbaeb095e05eba4c1685c25443bbf848125392960f38b315b6eb0",
"address":"ScXk96ma9D1m2w7bFbNUKx1yjbWCCEYMY5"
}
}
]
POST http://127.0.0.1:8282/mainnet/account
Query Parameters
Parameter | Type | Description |
---|---|---|
passphrase | string (query) |
secret passphrase |
Create/Get account from BIP38
Create (or get if already existing) account and encrypt using bip38
curl -X POST "http://127.0.0.1:8282/mainnet/account/bip38"
-d '{"bip38":"MasterPassword", "userid":"useridstring"}'
-H "Content-Type: application/json"
RESPONSE
[
{
"success":true,
"publicKey":"0371a0038eebac8f7e47e0bd10128a3dbe951d96bb09560cf972c05c31edb1cc2e",
"address":"SWSbAHmCrovRfMzQwkuhMoymMPXDZBw5jx",
"wif":"6PYR6wexqVbcfGjUo6gKKW7nYaVowVo3qSDXjXRsLTBDWTepH22kbLMsJT"
}
]
POST http://127.0.0.1:8282/mainnet/account/bip38
Query Parameters
Parameter | Type | Description |
---|---|---|
bip38 | string (query) |
master password |
userid | string (query) |
any username |
GET backup account from userid
curl -X GET "http://127.0.0.1:8282/{network}/account/bip38/{userid}"
-H "accept: application/json"
{network} - mainnet or testnet
RESPONSE
[
{
"success":true,
"wif":"6PYR6wexqVbcfGjUo6gKKW7nYaVowVo3qSDXjXRsLTBDWTepH22kbLMsJT"
}
]
GET http://127.0.0.1:8282/{network}/account/bip38
Get last transactions from address
curl -X GET "http://127.0.0.1:8282/{network}/transactions/{address}"
-H "accept: application/json"
{network} - mainnet or testnet
RESPONSE
[
{
"success":true,
"transactions":
[
{
"id":"c025f70cb32b9cfbf9160b95237c92d41644e1fdd4ead4a0052a07ffb5b97921",
"blockid":"15547375374841204258",
"type":0,
"timestamp":9156817,
"amount":17000000000,
"fee":10000000,
"senderId":"Sf6y6bFqdPiXt9qupmTdpJFJwBWmMCfs43",
"recipientId":"SZg73u3rVrqwahfZ2tU6G1E3YwDs52tMeW",
"senderPublicKey":"03e340952f7d726d8598b4ae68e88e583b39735c35b489559e082c705dba50376e",
"signature":"3045022100a2d732a3139ddbdaf27b9335894544fbcf590604c7e5a60a1ec72f295348f86402202f415d115c3390a6a45e81fec8c5f0177511aa421fd4ceb448262b334233ca96",
"asset":{},
"confirmations":927
},
{
"id":"41616c6d8393a55b3c911b400b14433e83ee3e3caf4dcedfb1684019b8566a3c",
"blockid":"13256355616806784710",
"type":0,
"timestamp":9156745,
"amount":17000000000,
"fee":10000000,
"senderId":"Sf6y6bFqdPiXt9qupmTdpJFJwBWmMCfs43",
"recipientId":"SkaPmhW8FwiZ1g64yEnyvcGRpY9ZyauPjz",
"senderPublicKey":"03e340952f7d726d8598b4ae68e88e583b39735c35b489559e082c705dba50376e",
"signature":"30440220141c637637bc40e14a5d49ada9257b487faff1061835c730325c05595fb7b582022065f8f0259baf41f49cba2b163b0d4934e12ca3a20239c36dce1e870bf9660cf7",
"asset":{},
"confirmations":935
},
...
],
"count":"132"
}
]
GET http://127.0.0.1:8282/{network}/transactions/{address}
Create a transaction
curl -X POST "http://127.0.0.1:8282/{network}/transaction"
-d '{"recipientId":"<address>","amount":"<AmountInSatoshi>","passphrase":"<SenderAddressPassPhrase>"}'
-H "Content-Type: application/json"
RESPONSE
[
{
"success":true,
"transaction":
{
"type":0,
"amount":10000000,
"fee":10000000,
"recipientId":"Sa9JKodiNeM7tbYjxwEhvvG1kBczhQxTN3",
"timestamp":9165933,
"asset":{},
"senderPublicKey":"03675c61dcc23eab75f9948c6510b54d34fced4a73d3c9f2132c76a29750e7a614",
"signature":"304402201342810cdd2db452aff3b4c6367101a6973f40d7d4601647a8433c7bc547bde902202629f5fae8405097147edb8e10839d58dc56f1f154dfe3db3a3dcfd7acf4bdb9",
"id":"477c43012b1720de6f924918ad1ee7e41fc74ef5ed30ed628ea3af877ad203f1"
}
}
]
POST http://127.0.0.1:8282/{network}/transaction
Example:
curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:8081/mainnet/transaction" -d '{"recipientId":"Sa9JKodiNeM7tbYjxwEhvvG1kBczhQxTN3","amount":"10000000","passphrase":"this is a test"}'
Broadcast transaction
curl -X POST "http://127.0.0.1:8282/{network}/broadcast"
-d '{"id":"<id of the transaction>"}'
-H "Content-Type: application/json"
RESPONSE
[
{
"success":true,
"transaction":
{
"type":0,
"amount":10000000,
"fee":10000000,
"recipientId":"Sa9JKodiNeM7tbYjxwEhvvG1kBczhQxTN3",
"timestamp":9165933,
"asset":{},
"senderPublicKey":"03675c61dcc23eab75f9948c6510b54d34fced4a73d3c9f2132c76a29750e7a614",
"signature":"304402201342810cdd2db452aff3b4c6367101a6973f40d7d4601647a8433c7bc547bde902202629f5fae8405097147edb8e10839d58dc56f1f154dfe3db3a3dcfd7acf4bdb9",
"id":"477c43012b1720de6f924918ad1ee7e41fc74ef5ed30ed628ea3af877ad203f1"
}
}
]
POST http://127.0.0.1:8282/{network}/broadcast
Example:
curl -X POST "http://127.0.01:8282/mainnet/broadcast" -H "accept: application/json" -H "content-type: application/json" -d '{"id":"477c43012b1720de6f924918ad1ee7e41fc74ef5ed30ed628ea3af877ad203f1"}'
Create a transaction using bip38
curl -X POST "http://127.0.0.1:8282/{network}/transaction/bip38"
-d '{"recipientId":"<recipientId>","amount":"<in satoshis>","bip38":"<password to encode wif>","userid":"<useridBip38>"}'
-H "Content-Type: application/json"
RESPONSE
[
{
"success":true,
"transaction":
{
"type":0,
"amount":10000000,
"fee":10000000,
"recipientId":"Sa9JKodiNeM7tbYjxwEhvvG1kBczhQxTN3",
"timestamp":9165933,
"asset":{},
"senderPublicKey":"03675c61dcc23eab75f9948c6510b54d34fced4a73d3c9f2132c76a29750e7a614",
"signature":"304402201342810cdd2db452aff3b4c6367101a6973f40d7d4601647a8433c7bc547bde902202629f5fae8405097147edb8e10839d58dc56f1f154dfe3db3a3dcfd7acf4bdb9",
"id":"477c43012b1720de6f924918ad1ee7e41fc74ef5ed30ed628ea3af877ad203f1"
}
}
]
POST http://127.0.0.1:8282/{network}/transaction/bip38
Example:
curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:8081/mainnet/transaction/bip38" -d '{"recipientId":"Sa9JKodiNeM7tbYjxwEhvvG1kBczhQxTN3","amount":"10000000","bip38":"this is a test","userid":"superuser38""}'
Errors
The API uses the following error codes:
When an error happens the API will return a HTTP message 400(bad request) combined with an error.
Response
HTTP/1.1 400 Bad Request
{
"error": 101,
"message": "invalid signature"
}
Error | Description |
---|---|
0 | Unknown error. |
1 | Json error. |
2 | Not enough balance. |
3 | Not yet released. |
101 | Invalid signature. |
102 | Invalid address. |
103 | Invalid seed. |
104 | Invalid amount. |
105 | Invalid fee. |
106 | Invalid sender. |
107 | Invalid recipient. |
108 | Invalid name length. |
109 | Invalid value length. |
110 | Invalid name owner. |
111 | Invalid buyer. |
112 | Invalid public key. |
113 | Invalid options length. |
114 | Invalid option length. |
115 | Invalid data. |
116 | Invalid data length. |
201 | Wallet does not exist. |
202 | Address does not exist in wallet. |
203 | Wallet is locked |
204 | Wallet already exists. |
301 | Block does not exist. |
311 | Transaction does not exist. |
401 | Name does not exist. |
402 | Name already exists. |
403 | Name already for sale. |
404 | Name must be lower case. |
410 | Name is not for sale. |
411 | Buyer is already the owner. |
501 | Poll does not exist. |
502 | Poll already exists. |
503 | Duplicate option. |
504 | Polloption does not exist. |
505 | Already voted for that option. |
Models
Accounts AddDelegatesRequest
Parameter | Type | Description |
---|---|---|
secret* | string | A valid account Passphrase. |
secondSecret | string | A valid secondary account Passphrase. |
publicKey* | string | A valid account Public Key. |
Delegates AddDelegateRequest
Parameter | Type | Description |
---|---|---|
secret* | string | A valid account Passphrase. |
secondSecret | string | A valid secondary account Passphrase. |
publicKey* | string | A valid account Public Key. |
username* | string | A valid SmartHoldem Delegate username. |
Multisignatures AddMultisignatureRequest
Parameter | Type | Description |
---|---|---|
secret* | string | A valid account Passphrase. |
secondSecret | string | A valid secondary account Passphrase. |
publicKey* | string | A valid account Public Key. |
min* | integer | min sugnatures (min 1 - max 16) |
lifetime* | integer | min 1 - max 72 |
keysgroup* | array [string] | A list of public keys. length 1 - 10 |
Signatures AddSignatureRequest
Parameter | Type | Description |
---|---|---|
secret* | string | A valid account Passphrase. |
secondSecret | string | A valid secondary account Passphrase. |
publicKey* | string | A valid account Public Key. |
multisigAccountPublicKey* | string | A valid multi signature SmartHoldem Public Key. |
Transactions AddTransactionsRequest
Parameter | Type | Description |
---|---|---|
secret* | string | A valid account Passphrase. |
secondSecret | string | A valid secondary account Passphrase. |
amount* | integer | An amount in satoshi as unsigned integer. |
recipientId* | string | A valid SmartHoldem Address. |
publicKey* | string | A valid account Public Key. |
multisigAccountPublicKey* | string | A valid multi signature SmartHoldem Public Key. |
Transport AddTransactionsRequest
Parameter | Type | Description |
---|---|---|
transactions* | [object] | A transaction object that should be processed. |
Accounts GetBalanceResponse
Parameter | Type | Description |
---|---|---|
success | boolean | Indicates whether or not errors occurred |
balance | integer | is usually equal to unconfirmedBalance |
unconfirmedBalance | integer | is usually equal to balance |
Accounts GetPublickeyResponse
Parameter | Type | Description |
---|---|---|
success | boolean | Indicates whether or not errors occurred |
publicKey | string | A valid SmartHoldem Public Key. |
Accounts GetDelegatesFeeResponse
Parameter | Type | Description |
---|---|---|
success | boolean | Indicates whether or not errors occurred |
fee | integer |
Accounts GetDelegatesResponse
Parameter | Type | Description |
---|---|---|
success | boolean | Indicates whether or not errors occurred |
delegates | object | delegate |
delegate.username | string | |
delegate.address | string | |
delegate.publicKey | string | |
delegate.vote | string | |
delegate.producedblocks | integer | |
delegate.missedblocks | integer | |
delegate.rate | integer | |
delegate.approval | number | |
delegate.productivity | number |