BlockIO
This Lib make integration with block.io in easy way.
With Block.io you can
create new wallets: Bitcoin, Dogecoin, Litecoin
look transactions
accept payments
make withdraws
etc
Demo bot
See DemoBlockIOBot. It also available in the Store.
See docs about this bot.
Initial setup
Need to set Api key and secret pin in first. You can create command /init
with such BJS:
Just run bot and execute this command /init
. Then you can remove it.
You get Secret PIN from Block.io by e-mail
You get API keys in Block.io dashboard by link "Show API Keys"
You can also provide pin and api key in commands in options
Methods
All methods from https://block.io/api available in the Lib.
You can run it via command:
XXXCoin - it is Bitcoin, Litecoin or Dogecoin
You can also use Testnet: Libs.BlockIO.testNet.XXXcoin
All methods
Method name for Libs.BlockIO.XXXcoin | Description |
getNewAddress | Returns a newly generated address, and its unique(!) label generated by Block.io. You can optionally specify a custom label. |
getBalance | Returns the balance of your entire Bitcoin, Litecoin, or Dogecoin account (i.e., the sum of balances of all addresses/users within it) as numbers to 8 decimal points, as strings. |
getAddressBalance | Returns the balance of the specified addresses, or labels. Upto 2500 addresses/labels can be specified per request. Can be used to query balances for external (non-account) addresses. If an external address' balance is returned, its user_id and label fields will be null. |
getMyAddresses | Returns the (unarchived) addresses, their labels, user ids, and balances on your account. Upto 2500 addresses per page. Page parameter is optional. |
getAddressByLabel | Returns the address specified by a label. |
isValidAddress | Returns whether a single specified address is valid for the network, or not. |
archiveAddresses | Archives upto 100 addresses in a single API call. Addresses can be specified by their labels. |
unarchiveAddresses | Unarchives upto 100 addresses in a single API call. Addresses can be specified by their labels. |
getMyArchivedAddresses | Returns all the archived addresses, their labels, and user ids on your account. |
getTransactions | Returns various data for the last 25 transactions spent or received. You can optionally specify a before_tx parameter to get earlier transactions. You can use this method to query for addresses that are not on your account. |
getRawTransaction | Returns the raw data, including transaction hex, for a given transaction ID. |
getNetworkFeeEstimate | Estimates the Network Fee you will need to pay when you make a withdrawal request. The Network Fee is required by the Bitcoin/Dogecoin/etc. networks, not Block.io. |
isGreenTransaction | Returns an array of transactions that were sent by Block.io Green Addresses. Funds sent from Green Addresses are guaranteed by Block.io, and can be used immediately on receipt with zero network confirmations. |
getCurrentPrice | Returns the prices from the largest exchanges for Bitcoin, Dogecoin, or Litecoin, specified by the API Key. Specifying the base currency is optional. |
withdraw | Withdraws amount of coins from any addresses in your account to up to 2500 destination addresses. |
withdrawFromAddresses | Withdraws AMOUNT coins from upto 2500 addresses at a time, and deposits it to up to 2500 destination addresses. |
withdrawFromLabels | Withdraws AMOUNT coins from upto 2500 labels at a time, and deposits it to upto 2500 destination addresses, or labels. |
Full methods docs here
So if you need, for example, getTransactions method for Litecoin change this code:
to:
What it is - "OTHER POSSIBLE PARAMS" ?
It can be:
api_key and pin. If you do not set here (for all methods)
label, address (for getNewAddress methods and etc)
labels, addresses
to_addresses, from_addresses, from_labels (for withdraw )
page
transaction_ids (for isGreenTransaction method)
type (for getTransactions method)
See available params in https://block.io/api page
Example for getNewAddress
For example: "Actions for Handling Addresses"
From block.io help:
So we have API method "Get New Address":
This function getNewAddress have 2 callbacks: onSuccess
and onError
.
onSuccess
callback command /onNewAddress
will be runned:
Example for making Withdraw
We know about params: to_addresses
and from_labels
from block.io help. See "Withdraw From Labels" method there
Transfer coin from Block.io wallet with label "default" to any wallet:
onWithdraw command:
Error handing
You can show error message from Block.io
How to...
Open new BTC address for each user (chat)?
possible BJS for command /newAddress:
command /onNewAddress:
command /onError:
How can I check any payment by user on block.io if I know him bitcoin address and payment will be 0,0001 Bitcoin?
Looks like you need to receive payments on one own wallet from several users.
It is bad practice:
User must say his wallet before payment. Because after payment anybody can see any addresses in blockchain
User can do mistake with his address wallet
User can do mistake with amount
Thus, users will have incorrect operations. You should check them in manual mode. It will be very difficult for you to verify incorrect transactions in the blockchain.
More good practice it is generate new income address for each payment. It is more secure.
Last updated