BLOC-service RPC Wallet is a HTTP server which provides JSON 2.0 RPC interface for BLOC payment operations and address management. bloc-service RPC Wallet allows you to accept incoming payments, generate an address for each user via bloc-service RPC Wallet JSON RPC API and much more.
BLOC-service RPC Wallet JSON API
Automated services and solutions with BLOC-service
Start BLOC-service with arguments and use this page to connect to your BLOC-service RPC Wallet. Make sure to enter the address exactly like on the exemple.
Once connected, you will be able to use all the functions described below.
A simple way to test your application or/and connect to a BLOC-service RPC Wallet and send commands.
Note: We are not saving any logs/requests on this website. Only you see the outputs.
BLOC integration
Make sure you follow this instructions before getting started with BLOC
BLOC integration process may differes from other cryptocurrencies. Firstly, the coin has three separate binaries:
We also support the following official client bindings:
Please click on each of the service you would like to use to see how does it work and how to implement BLOC into your application and/or website.
Getting started
Use the form below to test the integration of the bloc-service API into your application. Make sure you have filled the connexion details at the top of this page.
This section describes BLOC integration process into your service with BLOC e-commerce solution called BLOC-service RPC Wallet.
Each method has its own example and description that can be found by clicking the details button of this method.
To start using BLOC-service you must first generate a container. Container file is the only file that stores all data required to run your service. It contains user addresses and private keys required to operate them. Make sure to backup this file regularly. To generate a new container visit the BLOC-service RPC Wallet command line arguments and look at the --generate-container
function to read the explanation. More on how to start and operate BLOC-service RPC Wallet can be found here.
To start the BLOC-service JSON RPC API server at http://localhost:8070, run:
./BLOC-service
To make the server accessible from another computer, use the --rpc-bind-ip 0.0.0.0 switch.
./BLOCd --rpc-bind-ip=0.0.0.0
To make a JSON RPC request to your BLOC-service RPC Wallet you should use POST request that looks like this:
http://<service address>:<service port>/json_rpc
Where:
<service address>
is an IP of BLOC-service RPC Wallet, if RPC Wallet is located on local machine it is either 127.0.0.1 or localhost,<service port>
is BLOC-service RPC Wallet port, by default it is binded to 8070 port, but it can be manually binded to any port you want, read more about this here.
Make sure you have filled the connexion details at the top of this page. Once you are ready, scroll down until your favorite function, fill the details and click TRY IT OUT
button to send the request and get the the response.
reset()
method reset your wallet and re-sync from block 0 or specified block number.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
scanHeight | No | The height to begin scanning for transactions at. This can greatly speed up wallet syncing time. | integer | 100000 |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"reset","params":{params}}' http://machine.domain:port/json_rpc
<?php $scanHeight = 1000; $response = $blocService->reset($scanHeight); echo $response;
service.reset({ scanHeight: 1000 }).then(() => { // do something }).catch((error) => { // do something })
scanHeight := 0 // starting height to scan response, err := service.Reset(scanHeight) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{} } No output in case of success.
save()
method allows you to save your wallet by request.
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"save","params":{params}}' http://machine.domain:port/json_rpc
<?php $response = $blocService->save(); echo $response;
service.save().then(() => { // do something }).catch((error) => { // do something })
response, err := service.Save() if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{} }
getViewKey()
method returns your Private view key
Argument | Description | Format |
---|---|---|
viewSecretKey | Private view key | string |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getViewKey","params":{_params_}}' http://machine.domain:port/json_rpc
<?php $response = $blocService->getViewKey(); echo $response;
service.getViewKey().then((result) => { // do something }).catch((error) => { // do something })
response, err := service.GetViewKey() if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "viewSecretKey":"e0b250f7d56f9b7a4ac9b57e9c716dea731b59a7b3d06f51eacd9f5d0340630c" } }
getSpendKeys()
method returns your spendPublicKey and spendSecretKey
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
address | Yes | Valid address that exists in this container | string | abLoc8oL14r8DUdzXBPwN8LPMSBJfS3BaFG96gQPhFWRNBw2g6AHpFoJyuYP7h83cPEcLYxKAgMs9L27S3tBNEHaMkR6JhDsLt5 |
Argument | Description | Format |
---|---|---|
spendPublicKey | Public spend key | string |
spendSecretKey | Private spend key | string |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getSpendKeys","params":{params}}' http://machine.domain:port/json_rpc
<?php $address = 'abLoc...'; $response = $blocService->getSpendKeys($address); echo $response;
service.getSpendKeys({ address: 'abLoc....' }).then((result) => { // do something }).catch((error) => { // do something })
address := "abLoc..." response, err := service.GetSpendKeys(address) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "spendPublicKey":"92024ad72b22e70c7540027173e5cbe6f73d2b955542d8712d7ed3e27ead7811", "spendSecretKey":"cda47a19e5d433060ab79c885817cd20fc394dc7043ac875678a3698804ede01" } }
getMnemonicSeed()
method returns the mnemonic seed for the given deterministic address.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
address | Yes | Valid deterministic address that exists in this container | string | abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg |
Argument | Description | Format |
---|---|---|
mnemonicSeed | 25 words Mnemonic seed | string |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getMnemonicSeed","params":{params}}' http://machine.domain:port/json_rpc
<?php $address = 'abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg...'; $response = $blocService->getMnemonicSeed($address); echo $response;
service.getMnemonicSeed({ address: 'abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg' }).then((result) => { // do something }).catch((error) => { // do something })
address := "abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg" response, err := service.GetMnemonicSeed(address) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "mnemonicSeed":"dads vehicle fiat fountain repent radar aspire orbit awesome trolling guide drinks kickoff heron husband tutor onward legion nail yahoo arena were melting necklace vehicle" } }
getStatus()
method returns information about the current RPC Wallet state: block count known block count, last block hash and peer count.
Argument | Description | Format |
---|---|---|
blockCount | Node's known number of blocks | integer |
knownBlockCount | Maximum known number of blocks of all seeds that are connected to the node | integer |
lastBlockHash | Hash of the last known block | string |
peerCount | Connected peers number | integer |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getStatus","params":{params}}' http://machine.domain:port/json_rpc
<?php $response = $blocService->getStatus(); echo $response;
service.getStatus().then((result) => { // do something }).catch((error) => { // do something })
response, err := service.GetStatus() if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "blockCount": 104557, "knownBlockCount": 104557, "lastBlockHash":"7f717ceca1875e51419a7a07a7d985310805e0b089b0fc87fbbcfe93010a755a", "peerCount":8 } }
getAddresses()
returns an array of your RPC Wallet's addresses present in the container.
Argument | Description | Format |
---|---|---|
addresses | Array of strings, where each string is an address | array |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getAddresses","params":{params}}' http://machine.domain:port/json_rpc
<?php $response = $blocService->getAddresses(); echo $response;
service.getAddresses().then((result) => { // do something }).catch((error) => { //do something })
response, err := service.GetAddresses() if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "addresses":[ "abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg", "abLoc8YamWu4XUKddV9NZ4fk3WCqzL2XCPQh9yB7Pd88UDpmSCiZsdWYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgC9fRqa" ] } }
createAddress()
method creates an additional address called a subaddress in your wallet container file.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
spendSecretKey | No | Private spend key. If spendSecretKey was specified, RPC Wallet creates spend address | string | f4abd8dfc3ffea2c96b131c22340d4b437b9722407769c9449f24d1a8bad0c0e |
spendPublicKey | No | Public spend key. If publicSpendKey was specified, RPC Wallet creates view address | string | db20e68b00e69ba85d161af5378ab04551e0c10f23d1df6ea29da58ddc527b2e |
newAddress | No | Is this a new address being created? If so, blocks before the creation timestamp will not be scanned. Defaults to true if neither keys are given, as it is guaranteed to be a new address. | bool | true |
Argument | Description | Format |
---|---|---|
address | Array of string view, each string is an address | array |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"createAddress","params":{params}}' http://machine.domain:port/json_rpc
<?php $secretSpendKey = null; $publicSpendKey = null; $response = $blocService->createAddress($secretSpendKey, $publicSpendKey); echo $response;
service.createAddress({ secretSpendKey: '', publicSpendKey: '' }).then((result) => { // do something }).catch((error) => { //do something })
spendSecretKey := "" spendPublicKey := "" scanHeight := 8500 newAddress := true response, err := service.CreateAddress(spendSecretKey, spendPublicKey, scanHeight, newAddress) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "address":"abLocAiXVFeaF9JWodjvHrPYakpxf1Bfg1yoM11ydPBaNq4AXw5kbeUYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgB2VtRs" } }
deleteAddress()
method deletes a specified address from the wallet and container file.
Make sure you have a back up of your wallet before deleting it.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
address | Yes | An address to be deleted present in the wallet container file. | string | abLocv1pacKFJk9QgSmzk2LJWn14JGmTKzReFLz1RgY3K9Ryn7783RDT2TretzfYdck5GMCGzXTuwKfePWQYViNs4avKpnUbrwfQ |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"deleteAddress","params":{params}}' http://machine.domain:port/json_rpc
<?php $address = 'abLocv1pacKFJk9QgSmzk2LJWn14JGmTKzReFLz1RgY3K9Ryn7783RDT2TretzfYdck5GMCGzXTuwKfePWQYViNs4avKpnUbrwfQ'; $response = $blocService->deleteAddress($address); echo $response;
service.deleteAddress({ address: 'abLocv1pacKFJk9QgSmzk2LJWn14JGmTKzReFLz1RgY3K9Ryn7783RDT2TretzfYdck5GMCGzXTuwKfePWQYViNs4avKpnUbrwfQ' }).then((result) => { // do something })
address := "abLocv1pacKFJk9QgSmzk2LJWn14JGmTKzReFLz1RgY3K9Ryn7783RDT2TretzfYdck5GMCGzXTuwKfePWQYViNs4avKpnUbrwfQ" response, err := service.DeleteAddress(address) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
In case of success returns an empty JSON object. { "id":1, "jsonrpc":"2.0", "result":{} }
getBalance()
method returns a balance for a specified address.
If address is not specified, getBalance()
returns a cumulative balance of all RPC Wallet's addresses present in the container.
Also note, balances are expressed in BLOC atomic units, so a balance of 10000 is equal to 1 BLOC and a balance of 0.0001 BLOC = 1 BLOC Atomic unit.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
address | No | Valid address that exists in this container | string | abLoc8oL14r8DUdzXBPwN8LPMSBJfS3BaFG96gQPhFWRNBw2g6AHpFoJyuYP7h83cPEcLYxKAgMs9L27S3tBNEHaMkR6JhDsLt5 |
Argument | Description | Format |
---|---|---|
availableBalance | Available balance of the specified address in BLOC units | integer |
lockedAmount | Locked amount of the specified address in BLOC units. | integer |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getBalance","params":{params}}' http://machine.domain:port/json_rpc
<?php $address = 'abLoc8oL14r8DUdzXBPwN8LPMSBJfS3BaFG96gQPhFWRNBw2g6AHpFoJyuYP7h83cPEcLYxKAgMs9L27S3tBNEHaMkR6JhDsLt5'; $response = $blocService->getBalance($address); echo $response;
// Address optional service.getBalance({ address: 'abLoc8oL14r8DUdzXBPwN8LPMSBJfS3BaFG96gQPhFWRNBw2g6AHpFoJyuYP7h83cPEcLYxKAgMs9L27S3tBNEHaMkR6JhDsLt5' }).then((result) => { // do something })
address := "abLoc8oL14r8DUdzXBPwN8LPMSBJfS3BaFG96gQPhFWRNBw2g6AHpFoJyuYP7h83cPEcLYxKAgMs9L27S3tBNEHaMkR6JhDsLt5" response, err := service.GetBalance(address) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "availableBalance":10000, "lockedAmount":0 } }
getBlockHashes()
method returns an array of block hashes for a specified block range.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
firstBlockIndex | Yes | Starting height | integer | 100000 |
blockCount | Yes | Number of blocks to process | integer | 10 |
Argument | Description | Format |
---|---|---|
blockHashes | Array of strings, where each element is a block hash | array |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getBlockHashes","params":{params}}' http://machine.domain:port/json_rpc
<?php $firstBlockIndex = 100000; $blockCount = 10; $response = $blocService->getBlockHashes($firstBlockIndex, $blockCount); echo $response;
service.getBlockHashes({ firstBlockIndex: 100000, blockCount: 10 }).then((result) => { // do something })
firstBlockIndex := 100000 blockCount := 10 response, err := service.GetBlockHashes(firstBlockIndex, blockCount) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "blockHashes":[ 'e026316d0b95436a7d3d36247fc8adb5fcb342015eccc239b346a7e2fd64c262', 'd73f01f1417386243bd14854acd75817c853aee1b42bb805498a59b19f7c9b90', 'e538987e328c9166d88b60c3f78763bf14ec08a619179d96b8154712e6306f4f', 'f128754b54cbf1a93cd4e743f9ba0a44a8a8e00c614324145cb80b36f5349200', '7ff0a7a78aeb01e7bd9b835642218d25dd153b001c1658b9869efdcd5d01cb6b', '26238a80a7c52c8930b89053460e60a599e89d293cbea5f680911ecb2d000ade', '56cf58de9e0d22c83c4bed757bdb56a35ad38364e5380ce3edbfb83dfc268e81', '7661d773cd5ffc56a3e6e3deb377c8e0be5f46e9403d1000adb6055fd4ac5343', 'f7904821432dfdbb127419d885d292b56e9853e11468d9fa0e59c5906bf5db52', 'bd3dd101b769fc8b04949f9663c5bef3fa0578848c924281bc7487eb50b68c49' ] } }
getTransactionHashes()
returns an array of block and transaction hashes
A transaction consists of transfers. A transfer is an amount-address pair.
There could be several transfers in a single transaction.
If paymentId parameter is set, getTransactionHashes()
method returns transaction hashes of transactions that contain specified payment ID in the given block range.
If addresses parameter is set, getTransactionHashes()
method returns transaction hashes of transactions that contain transfer from at least one of specified addresses.
If both above mentioned parameters are set, getTransactionHashes()
method returns transaction hashes of transactions that contain both specified payment ID and transfer from at least one of specified addresses.
Only one of either blockHash or firstBlockIndex may be supplied, but not both.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
addresses | No | Array of strings, where each string is an address | array | abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg, abLoc8YamWu4XUKddV9NZ4fk3WCqzL2XCPQh9yB7Pd88UDpmSCiZsdWYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgC9fRqa |
blockHash | No | Only one of these parameters (blockHash or firstBlockIndex) is allowed. Hash of the starting block. | string | 5339e77b028a29ace5cfb2d94c1fe869dd810aed3a9d7e1280aa192311e427e5 |
firstBlockIndex | No | Only one of these parameters (blockHash or firstBlockIndex) is allowed. Starting height >0 (1,2,3...) | integer | 1 |
Argument | Description | Format |
---|---|---|
items | array | |
items.blockHash | Hash of the block which contains transaction hashes | string |
items.transactionHashes | Array of strings, where each string is a transaction hash | array |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getTransactionHashes","params":{params}}' http://machine.domain:port/json_rpc
<?php $blockCount = 1000; $firstBlockIndex = 4000; $blockHash = null; $addresses = null; $paymentId = null; $response = $blocService->getTransactionHashes( $blockCount, $firstBlockIndex, $blockHash, $addresses, $paymentId ); echo $response;
service.getTransactionHashes({ addresses: [ "abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg", "abLoc8YamWu4XUKddV9NZ4fk3WCqzL2XCPQh9yB7Pd88UDpmSCiZsdWYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgC9fRqa" ], blockHash: '5339e77b028a29ace5cfb2d94c1fe869dd810aed3a9d7e1280aa192311e427e5', blockCount: 1 }).then((result) => { // do something })
addresses := []string{"abLoc8YamWu4XUKddV9NZ4fk3WCqzL2XCPQh9yB7Pd88UDpmSCiZsdWYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgC9fRqa"} blockHash := "" firstBlockIndex := 0 blockCount := 10000 paymentID := "" response, err := service.GetTransactionHashes(addresses, blockHash, firstBlockIndex, blockCount, paymentID) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "items":[ { blockHash: 'd537de1cd0492c67b49cbbe569c91a4f564bdd16dc4dc19c0f09172ee82da23c', transactionHashes: [ '6a7028e29b5796a31d2cbe5aeb5931694fe15caf0639c26045c9ac8103130a44' ] } ] } }
getTransactions()
method returns an array of block and transaction hashes.
A transaction consists of transfers. A transfer is an amount-address pair.
There could be several transfers in a single transaction.
If paymentId parameter is set, getTransactions()
method returns transaction hashes of transactions that contain specified payment ID in the given block range.
If addresses parameter is set, getTransactions()
method returns transaction hashes of transactions that contain transfer from at least one of specified addresses.
If both above mentioned parameters are set, getTransactions()
method returns transaction hashes of transactions that contain both specified payment ID and transfer from at least one of specified addresses.
Only one of either blockHash or firstBlockIndex may be supplied, but not both.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
addresses | No | Array of strings, where each string is an address | array | abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg, abLoc8YamWu4XUKddV9NZ4fk3WCqzL2XCPQh9yB7Pd88UDpmSCiZsdWYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgC9fRqa |
blockHash | No | Only one of these parameters (blockHash or firstBlockIndex) is allowed. Hash of the starting block. | string | bd95d859d58575f2a8685712354cd48e02f492080bc2f8c2447ebdc41f3dec68 |
firstBlockIndex | No | Only one of these parameters (blockHash or firstBlockIndex) is allowed. Starting height >0 (1,2,3...) | integer | 104570 |
Argument | Description | Format |
---|---|---|
items | array | |
items.block_hash | hash of the block which contains a transaction | string |
transactions | see below | array |
transactions.transactionHash | Hash of the transaction | string |
transactions.blockIndex | Number of the block that contains a transaction | integer |
transactions.timestamp | Timestamp of the transaction | integer |
transactions.isBase | Shows if the transaction is a CoinBase transaction or not | bool |
transactions.unlockTime | Height of the block when transaction is going to be available for spending | integer |
transactions.amount | Amount of the transaction | integer |
transactions.fee | Transaction fee | integer |
transactions.extra | Hash of the transaction | string |
transactions.paymentId | Payment ID of the transaction (optional) | string |
transactions.transfers | Array of address (string), amount (int) | array |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getTransactions","params":{params}}' http://machine.domain:port/json_rpc
<?php $blockCount = 1000; $firstBlockIndex = 4000; $blockHash = null; $addresses = null; $paymentId = null; $response = $blocService->getTransactions( $blockCount, $firstBlockIndex, $blockHash, $addresses, $paymentId ); echo $response;
service.getTransactions({ addresses: [ "abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg", "abLoc8YamWu4XUKddV9NZ4fk3WCqzL2XCPQh9yB7Pd88UDpmSCiZsdWYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgC9fRqa" ], firstBlockIndex: 40000, blockCount: 1 }).then((result) => { // do something })
addresses := []string{"abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg"} blockHash := "" firstBlockIndex := 0 blockCount := 3 paymentID := "" response, err := service.GetTransactions(addresses, blockHash, firstBlockIndex, blockCount, paymentID) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "items":[ { blockHash: 'd537de1cd0492c67b49cbbe569c91a4f564bdd16dc4dc19c0f09172ee82da23c', transactionAmount: 5, blockIndex: 104572, extra: '01800383a3084f99580038e74d2a02cdc104384ec7bc95243753595c10bf03e784', fee: 1, isBase: false, paymentId: '', state: 0, timestamp: 1540835452, transactionHash: '6a7028e29b5796a31d2cbe5aeb5931694fe15caf0639c26045c9ac8103130a44', address: 'abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg', amount: 5, type: 0, inbound: true, unlockTime: 0 } ] } }
getUnconfirmedTransactionHashes()
method returns an array of the current unconfirmed transaction pool or for a specified addresses.
A transaction consists of transfers. A transfer is an amount-address pair.
There could be several transfers in a single transaction.
If addresses parameter is set, getUnconfirmedTransactionHashes()
method returns transaction hashes of transactions that contain transfer from at least one of specified addresses.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
addresses | No | Array of strings, where each string is a valid address | array | abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg |
Argument | Description | Format |
---|---|---|
transactionHashes | Array of strings, where each string is a hash of an unconfirmed transaction | array |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getUnconfirmedTransactionHashes","params":{params}}' http://machine.domain:port/json_rpc
<?php $addresses = null; $response = $blocService->getUnconfirmedTransactionHashes($addresses); echo $response;
service.getUnconfirmedTransactionHashes({ address: 'abLocAR4dJi14yKV7ixsMMhW77HZt8c6HCYM5qdJDnwkDQByQwbBbPAYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgBaK6xg' }).then((result) => { // do something })
addresses := []string{"abLoc8YamWu4XUKddV9NZ4fk3WCqzL2XCPQh9yB7Pd88UDpmSCiZsdWYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgC9fRqa"} response, err := service.GetUnconfirmedTransactionHashes(addresses) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "transactionHashes":[ "f731190b013ac313d6cf2edba86e1e1fe1f0220c2bb59b80d817b0957f0d0e4d" ] } }
getTransaction()
method returns information about a particular transaction.
Transaction consists of transfers. Transfer is an amount-address pair. There could be several transfers in a single transaction.
Remember amounts are expressed in BLOC Atomic units, so an amount of 10000 is equal to 1 BLOC and an amount of 1 equal to 0.0001 BLOC
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
transactionHash | Yes | Array of strings, where each string is a hash of an unconfirmed transaction | string | be348bfb7f814fb40a4cde1d923daa4d90127534664c001d74f61f6ac6c88c92 |
Argument | Description | Format |
---|---|---|
transactionHash | Hash of the transaction | string |
blockIndex | Number of the block that contains a transaction | integer |
timestamp | Timestamp of the transaction | integer |
isBase | Shows if the transaction is a CoinBase transaction or not | bool |
unlockTime | Height of the block when transaction is going to be available for spending | integer |
amount | Amount of the transaction | integer |
fee | Transaction fee | integer |
extra | Hash of the transaction | string |
paymentId | Payment ID of the transaction (optional) | string |
transfers | Array of addresses (string), amount (int) | array |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getTransaction","params":{params}}' http://machine.domain:port/json_rpc
<?php $transactionHash = '5339e77b028a29ace5cfb2d94c1fe869dd810aed3a9d7e1280aa192311e427e5'; $response = $blocService->getTransaction($transactionHash); echo $response;
service.getTransaction({ transactionHash: 'be348bfb7f814fb40a4cde1d923daa4d90127534664c001d74f61f6ac6c88c92' }).then((result) => { // do something })
transactionHash := "5339e77b028a29ace5cfb2d94c1fe869dd810aed3a9d7e1280aa192311e427e5" response, err := service.GetTransaction(transactionHash) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "transaction":{ amount: -3995, blockIndex: 106556, extra: '01d09134d1821dd762ab8ddbfe7c4fa37d67bebf090c22ee99630b2ddce5265e1c', fee: 1, isBase: false, paymentId: '', state: 0, timestamp: 1541078180, transactionHash: 'be348bfb7f814fb40a4cde1d923daa4d90127534664c001d74f61f6ac6c88c92', transfers: [ { address: 'abLoc8oL14r8DUdzXBPwN8LPMSBJfS3BaFG96gQPhFWRNBw2g6AHpFoJyuYP7h83cPEcLYxKAgMs9L27S3tBNEHaMkR6JhDsLt5', amount: -3995, type: 0 }, { address: '', amount: 3994, type: 0 } ], unlockTime: 0 } } }
sendTransaction()
method allows you to send transaction(s) to one or several addresses. Also, it allows you to use a payment ID for a transaction to a single address.
Remember amounts are expressed in BLOC full units, so an amount of 10000 is equal to 1 BLOC and an amount of 1 equal to 0.0001 BLOC
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
addresses | No | Array of strings, where each string is an address to take the funds from | array | abLoc8oL14r8DUdzXBPwN8LPMSBJfS3BaFG96gQPhFWRNBw2g6AHpFoJyuYP7h83cPEcLYxKAgMs9L27S3tBNEHaMkR6JhDsLt5 |
transfers.address | Yes | Beneficiary of the transfer | string | abLoc8oL14r8DUdzXBPwN8LPMSBJfS3BaFG96gQPhFWRNBw2g6AHpFoJyuYP7h83cPEcLYxKAgMs9L27S3tBNEHaMkR6JhDsLt5 |
transfers.amount | Yes | Amount to transfer | integer | 10 |
fee | Yes | Transaction fee. Minimal fee in BLOC network is 0.0001 BLOC. As with other amounts use whole units, 1 BLOC = 1000 units, so 0.0001 BLOC = 1 unit | integer | 1 |
Argument | Description | Format |
---|---|---|
transactionHash | Hash of the sent transaction | string |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"sendTransaction","params":{params}' http://machine.domain:port/json_rpc
<?php $anonymity = 0; $fee = 1; $addresses = null; $unlockTime = null; $extra = null; $paymentId = null; $changeAddress = 'abLocyyyy...'; $transfers = [ ["address" => "abLocxxxx...", "amount" => 5000], ]; $response = $blocService->sendTransaction( $anonymity, $transfers, $fee, $addresses, $unlockTime, $extra, $paymentId, $changeAddress ); echo $response;
service.sendTransaction({ transfers: [ service.newTransfer('abLoc8YamWu4XUKddV9NZ4fk3WCqzL2XCPQh9yB7Pd88UDpmSCiZsdWYZuE4QGJVYfRc1TPmysMAuioPFuanAumEQoKCgC9fRqa', 100) ], fee: 1 }).then((result) => { // do something })
addresses := []string{"abLocyyyy..."} // can be empty unlockTime := 0 extra := "" paymentID := "" fee := 1 changeAddress := "abLocyyyy..." transfers := []map[string]interface{}{ { "address" : "abLocxxxx...", "amount" : 5000, }, } response, err := service.SendTransaction(addresses, transfers, fee, unlockTime, extra, paymentID, changeAddress) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "transactionHash":"0f3543118e5bc1e806ef28550f2199b653f25c913d5923bd635b95bc0020b747" } }
createDelayedTransaction()
method creates a delayed transaction. Such transactions are not sent into the network automatically and should be pushed using sendDelayedTransaction
method.
Remember amounts are expressed in BLOC atomic units, so an amount of 10000 is equal to 1 BLOC and an amount of 1 equal to 0.0001 BLOC
Outputs that were used for this transactions will be locked until the transaction is sent or cancelled
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
addresses | No | Array of strings, where each string is an address to take the funds from | array | TbLoc2R5d7HgwdAsnyLGnjS52z22v97LpVxdXwRaLwfw3sLadcYCiBEANSj3C7LpwbSx5UPnARB2xcZhHu1Q5jtaDsKfHKk5BXc |
transfers.address | Yes | Beneficiary of the transfer | string | abLoc8oL14r8DUdzXBPwN8LPMSBJfS3BaFG96gQPhFWRNBw2g6AHpFoJyuYP7h83cPEcLYxKAgMs9L27S3tBNEHaMkR6JhDsLt5 |
transfers.amount | Yes | Amount to transfer | string | 10 |
fee | Yes | Transaction fee. Minimal fee in BLOC network is 0.0001 BLOC. As with other amounts use whole units, 1 BLOC = 1000 units, so 0.0001 BLOC = 1 unit | integer | 1 |
Argument | Description | Format |
---|---|---|
transactionHash | Hash of the sent transaction | string |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"createDelayedTransaction","params":{params}}' http://machine.domain:port/json_rpc
<?php $anonymity = 0; $fee = 1; $addresses = null; $unlockTime = null; $extra = null; $paymentId = null; $changeAddress = 'abLocyyyy...'; $transfers = [ ["address" => "abLocxxxx...", "amount" => 5000], ]; $response = $blocService->createDelayedTransaction( $anonymity, $transfers, $fee, $addresses, $unlockTime, $extra, $paymentId, $changeAddress ); echo $response;
service.createDelayedTransaction({ transfers: [ service.newTransfer('abLoc', 100) ], fee: 1 }).then((result) => { // do something })
addresses := []string{"abLocyyyy..."} // can be empty unlockTime := 0 extra := "" paymentID := "" fee := 1 changeAddress := "abLocyyyy..." transfers := []map[string]interface{}{ { "address" : "abLocxxxx...", "amount" : 5000, }, } response, err := service.CreateDelayedTransaction(addresses, transfers, fee, unlockTime, extra, paymentID, changeAddress) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "transactionHash":"ae57e..." } }
getDelayedTransactionHashes ()
method returns hashes of delayed transactions.
Argument | Description | Format |
---|---|---|
transactionHashes | Array of strings, where each string is a transaction hash | string |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getDelayedTransactionHashes","params":{params}}' http://machine.domain:port/json_rpc
<?php $response = $blocService->getDelayedTransactionHashes(); echo $response;
service.getDelayedTransactionHashes().then((result) => { // do something })
response, err := service.GetDelayedTransactionHashes() if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "transactionHashes":["b3e374..."] } }
deleteDelayedTransaction ()
method deletes a specified delayed transaction.
In case of success returns an empty JSON object.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
transactionHash | Yes | Valid, existing delayed transaction hash | string | 665d5cdd1aab703c0bfd872333ba26a65b282a76600da46260e39300565d9f5a |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"deleteDelayedTransaction","params":{}}' http://localhost:8070/json_rpc
<?php $transactionHash = '665d5cdd1aab703c0bfd872333ba26a65b282a76600da46260e39300565d9f5a'; $response = $blocService->deleteDelayedTransaction($transactionHash); echo $response;
service.deleteDelayedTransaction({ transactionHash: '665d5cdd1aab703c0bfd872333ba26a65b282a76600da46260e39300565d9f5a' }).then((result) => { // do something })
transactionHash := "665d5cdd1aab703c0bfd872333ba26a65b282a76600da46260e39300565d9f5a" response, err := service.DeleteDelayedTransaction(transactionHash) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{} }
sendDelayedTransaction ()
method sends a specified delayed transaction.
In case of success returns an empty JSON object.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
transactionHash | Yes | Valid, existing delayed transaction hash | string | 665d5cdd1aab703c0bfd872333ba26a65b282a76600da46260e39300565d9f5a |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"sendDelayedTransaction","params":{params}}' http://machine.domain:port/json_rpc
<?php $transactionHash = '665d5cdd1aab703c0bfd872333ba26a65b282a76600da46260e39300565d9f5a'; $response = $blocService->sendDelayedTransaction($transactionHash); echo $response;
service.sendDelayedTransaction({ transactionHash: '665d5cdd1aab703c0bfd872333ba26a65b282a76600da46260e39300565d9f5a' }).then((result) => { // do something })
transactionHash := "665d5cdd1aab703c0bfd872333ba26a65b282a76600da46260e39300565d9f5a" response, err := service.SendDelayedTransaction(transactionHash) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{} }
sendFusionTransaction()
method allows you to send a fusion transaction, by taking funds from selected addresses and transferring them to the destination address. If there aren't any outputs that can be optimized, sendFusionTransaction()
will return an error. You can use estimateFusion ()
to check the outputs, available for the optimization
In the rest of the cases, destinationAddress field is mandatory and must contain an address.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
threshold | Yes | Value that determines which outputs will be optimized. Only the outputs, lesser than the threshold value, will be included into a fusion transaction. | integer | 1 |
anonymity | Yes | Privacy (mixin) (level from 0 to 10) | integer | 0 |
addresses | No | Array of strings, where each string is an address to take the funds from. | array | abLoc2R5d7HgwdAsnyLGnjS52z22v97LpVxdXwRaLwfw3sLadcYCiBEANSj3C7LpwbSx5UPnARB2xcZhHu1Q5jtaDsKfHKk5BXc |
Argument | Description | Format |
---|---|---|
transactionHash | Hash of the sent transaction | string |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"sendFusionTransaction","params":{}}' http://localhost:8070/json_rpc
<?php $threshold = 1000000; $anonymity = 0; $addresses = ['abLocyyyy...', 'abLocyyyy...']; $destinationAddress = 'abLoczzzz...'; $response = $blocService->sendFusionTransaction($threshold, $anonymity, $addresses, $destinationAddress); echo $response;
service.sendFusionTransaction({ destinationAddress: 'abLocyyyy' }).then((result) => { // do something })
threshold := 100000 addresses := []string{"abLocxxxx...", "abLocyyyy..."} destinationAddress := "abLoczzzz..." response, err := service.SendfusionTransaction(threshold, addresses, destinationAddress) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "transactionHash":"93faed..." } }
estimateFusion()
method counts the number of unspent outputs of the specified addresses and returns how many of those outputs can be optimized. This method is used to understand if a fusion transaction can be created.
If fusionReadyCount returns a value = 0, then a fusion transaction cannot be created.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
threshold | Yes | Value that determines which outputs will be optimized. Only the outputs, lesser than the threshold value, will be included into a fusion transaction. | integer | 1 |
addresses | No | Array of strings, where each string is an address to take the funds from. | array | abLoc2R5d7HgwdAsnyLGnjS52z22v97LpVxdXwRaLwfw3sLadcYCiBEANSj3C7LpwbSx5UPnARB2xcZhHu1Q5jtaDsKfHKk5BXc |
Argument | Description | Format |
---|---|---|
totalOutputCount | Total number of unspent outputs of the specified addresses. | integer |
fusionReadyCount | Number of outputs that can be optimized. | integer |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"estimateFusion","params":{params}}' http://machine.domain:port/json_rpc
<?php $threshold = 1000000; $addresses = ['abLocyyyy...', 'abLocxxxx...']; $response = $blocService->estimateFusion($threshold, $addresses); echo $response;
service.estimateFusion({ threshold: 100000000, addresses:[ 'abLocyyy.....' ] }).then((result) => { // do something })
threshold := 1000000 addresses := []string{"abLocyyyy...","abLocxxxx..."} response, err := service.EstimateFusion(threshold, addresses) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id":1, "jsonrpc":"2.0", "result":{ "fusionReadyCount":0, "totalOutputCount":8 } }
createIntegratedAddress()
method allows you to create a combined address, containing a standard address and a paymentId, to be used in sendTransaction()
or for supplying to a user, instead of using an address and paymentId as separate parameters.
This is helpful to ensure users cannot forget to supply a payment Id.
Argument | Mandatory | Description | Format | Example |
---|---|---|---|---|
address | Yes | A valid address present in the container | string | abLoc2R5d7HgwdAsnyLGnjS52z22v97LpVxdXwRaLwfw3sLadcYCiBEANSj3C7LpwbSx5UPnARB2xcZhHu1Q5jtaDsKfHKk5BXc |
paymentId | Yes | A valid paymentId | string | 4126541177d951210fa7d8f8bfabcd76b3a839724248f1b3404e5785fa506e62 |
Argument | Description | Format |
---|---|---|
integratedAddress | The created integrated address | string |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"createIntegratedAddress","params":{params}}' http://machine.domain:port/json_rpc
<?php $address = 'abLocyyyy...'; $paymentId = '4126541177d951210fa7d8f8bfabcd76b3a839724248f1b3404e5785fa506e62'; $response = $blocService->createIntegratedAddress($address, $paymentId); echo $response;
service.createIntegratedAddress({ address: 'abLocyyyy....', paymentId: '4126541177d951210fa7d8f8bfabcd76b3a839724248f1b3404e5785fa506e62' }).then((result) => { // do something })
address := "abLocyyyy..." paymentID := "4126541177d951210fa7d8f8bfabcd76b3a839724248f1b3404e5785fa506e62" response, err := service.CreateIntegratedAddress(address, paymentID) if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id": 1, "jsonrpc": "2.0", "result": { "integratedAddress": "abLocxxxxx..." } }
getFeeInfo()
method retrieves the fee and address (if any) from a remote node. This fee will automatically be added to any transactions sent by sendTransaction()
or sendDelayedTransaction()
using this node.
Note it does not apply to sendFusionTransaction()
.
Argument | Description | Format |
---|---|---|
address | The address of the node owner | string |
amount | The fee that will be sent to the node owners address with each transaction. | integer |
curl -d '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"getFeeInfo","params":{params}}' http://machine.domain:port/json_rpc
<?php $response = $blocService->getFeeInfo(); echo $response;
service.getFeeInfo().then((result) => { // do something })
response, err := service.GetFeeInfo() if err != nil { fmt.Println(err) } else { fmt.Println(response) }
{ "id": 1, "jsonrpc": "2.0", "result": { "address": "abLocyyy...", "amount": 5000 } }
autoOptimize()
method consists to create Fusion transactions.
Fusion transactions take all your (small) incoming payments and combine them into bigger ones, allowing you to send huge sums at once! It is strongly recommended to optimize your wallet, specially if you are mining BLOC and receiving a lot of small transactions.
You can use a cron-job to autoOptimize the wallet automatically every 5 minutes for exemple.
Argument | Description | Format |
---|---|---|
TXHASH | Transaction hash of the fusion transaction sent | string |
curl -X POST '{"jsonrpc":"2.0","id":1,"password":"passw0rd","method":"autoOptimize","params":{params}' http://machine.domain:port/json_rpc
<?php $response = $blocService-> autoOptimize(); echo $response;
service.autoOptimize().then((result) => { // do something })
response, err := service.autoOptimize() if err != nil { fmt.Println(err) } else { fmt.Println(response) }
TXHASH: d105e9dd74edd51bf327cbce71a626d11348cd94f520026c2d4b9895ce833edc or: {"error":{"code":-32700,"data":{"application_code":8},"message":"Wallet is already optimized"}