Author Topic: [API] Bitshares integration to crypto-balances package  (Read 4602 times)

0 Members and 1 Guest are viewing this topic.

Offline 21xhipster

very nice ..

since you are now running a witness node .. would you like to have it added to the wallet as a fall back API server?
Sure, if you point how to do that :-)
https://cyber.fund/ - Decetnralized Investment Platform

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
Everybody thanks. @abit @xerox We've manage to do it.
https://blog.cyber.fund/blockchain-balances-2cdb4a710f8
Congras :)

One thing I'd like to mention here: the witness_node is now using more and more memory while time passing by. I've said "2GB is more than enough", but probably it will not be enough soon.
BitShares committee member: abit
BitShares witness: in.abit

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
very nice ..

since you are now running a witness node .. would you like to have it added to the wallet as a fall back API server?

Offline 21xhipster

https://cyber.fund/ - Decetnralized Investment Platform

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
Hey there,

good to have you on board and your are doing a great job!
I would recommend to take a look into https://github.com/cryptonomex/graphene-ui/tree/master/dl
this directory contains quite a nice amount of coffeescript and es6 code that deals with the bts blockchain.

There is also a python library https://github.com/xeroc/python-graphenelib
and a lot of documentation about the API of BitShares and how to use it:
http://docs.bitshares.org/api

It's late over here and I would leave you with these for now .. If you have more questions, don't hesitate to drop me a line either here or in slack.
@besson I'd like to extend a question!
AFAIK BitShares node require 32GB RAM. Such DigitalOcean instance cost $320 monthly. It's quite expensive for our small project to maintain such node just for checking BTS balances (our overall server costs now about $250). @besson @xerox Is there any possibility to use publicly available nodes or some centralized APIs now? Because if not though necessary functional concerning BitShares will be implement in a Quantum library it will not be used in production on https://cyber.fund and BitShares will be the only without support that is literally bad.
Currently, with BitShare 2.0, 2GB RAM is more than enough for witness nodes. The 32GB thing is maybe refer to BitShares 0.x.

Hello bitshares community. Nice to meet you, guys.
I am developer in cyber.fund and now I'm working on crypto-balances library which written with CoffeeScript.
You can easy check addresses balances of various crypto tokens. Script automaticaly recognize a protocol by address and return balance of tokens associated with it.
Library supports following: Bitcoin, Litecoin, Dogecoin, Ethereum, Counterparty, Open Assets, Ripple and IOUs, NXT and NXT AE, NEM, Dash and some other altcoins
In current milestone I'm working on Factom(done), Omni(done) and Bitshares.
I spent a lot of time trying to figure out how bitshares and ecosystem works.
So, I need yours help guys. What I have at this point:
1. Found that bitshares addresses have regex like  BTS[a-zA-Z0-9]{50} (for example BTS7tqXBbtJwDoT8b2LY3kx547ocVfSacTirBMFEsDyhGf2FNR48p)
2. Wrote code for RPC API calls.
3. Started my own node using digital ocean instances for tests.
4. Googled and read bitshares docs and now I'm really confused about bitshares API.
Methods which I found not working and another ones use ids and names, not addresses to return balance.
(blockchain_get_balance, blockchain_list_address_balances, get_account_balances, get_named_account_balances)
Maybe I missed something out, don't know
So, to finish milestone with bitshares integration I need api which can return balance on address and nodes which will return responses.
Sorry for my english guys, I didn't have enough practice. Hope for your help and advices  :)
The first 2 APIs you mentioned above is outdated, they are for BitShares 0.x. Currently with BitShares 2.0 we have new APIs (the last two), you need to take a look at http://docs.bitshares.org/api.

BTS now no longer uses addresses to store balances. The new APIs for balances is documented in libraries/app/include/graphene/app/database_api.hpp
Code: [Select]
      /**
       * @brief Get an account's balances in various assets
       * @param id ID of the account to get balances for
       * @param assets IDs of the assets to get balances of; if empty, get all assets account has a balance in
       * @return Balances of the account
       */
      vector<asset> get_account_balances(account_id_type id, const flat_set<asset_id_type>& assets)const;

      /// Semantically equivalent to @ref get_account_balances, but takes a name instead of an ID.
      vector<asset> get_named_account_balances(const std::string& name, const flat_set<asset_id_type>& assets)const;

In regards to nodes, you have several options:
* set up your own witness_node and cli_wallet, connect your application with your cli_wallet, so you can use command-like APIs (raw RPC or HTTP-RPC calls).
* find a public API server, for example wss://bitshares.openledger.info/ws which can be found in the light client setting, set up your own cli_wallet to connect to that API server, then do command-like RPC calls
* connect your application with the API server or witness_node directly via web socket, so you can do request/response style API calls as well as subscription/notification, however the APIs of API servers are a bit different to wallet APIs.
* use APIs of cryptofresh.com, which is one of BitShares's public block explorer.

So, if your application communicates with cli_wallet, the correct syntax would be like:
Code: [Select]
{"jsonrpc": "2.0", "method": "list_account_balances", "params":["an_account_name"], "id":1}

Any questions please don't hesitate to ask :)
« Last Edit: February 26, 2016, 09:48:44 am by abit »
BitShares committee member: abit
BitShares witness: in.abit

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
@xerox Is there any possibility to use publicly available nodes or some centralized APIs now? Because if not though necessary functional concerning BitShares will be implement in a Quantum library it will not be used in production on https://cyber.fund and BitShares will be the only without support that is literally bad.
you can of course use publicly available nodes such as wss://bitshares.openledger.info and there are more public servers coming .. I personally have never heard of a "quantum library".

Try this:
http://docs.bitshares.eu/api/websocket.html#example-call-with-wscat
against the openledger api server above

Xeldal

  • Guest
Bts only requires 8gb of ram.

I'm running nodes with much less.  I've got a 4 GB, 2GB, and even a 512MB .  They all do quite well at the moment.

Offline sittingduck

  • Sr. Member
  • ****
  • Posts: 246
    • View Profile

Offline 21xhipster

Hey there,

good to have you on board and your are doing a great job!
I would recommend to take a look into https://github.com/cryptonomex/graphene-ui/tree/master/dl
this directory contains quite a nice amount of coffeescript and es6 code that deals with the bts blockchain.

There is also a python library https://github.com/xeroc/python-graphenelib
and a lot of documentation about the API of BitShares and how to use it:
http://docs.bitshares.org/api

It's late over here and I would leave you with these for now .. If you have more questions, don't hesitate to drop me a line either here or in slack.
@besson I'd like to extend a question!
AFAIK BitShares node require 32GB RAM. Such DigitalOcean instance cost $320 monthly. It's quite expensive for our small project to maintain such node just for checking BTS balances (our overall server costs now about $250). @besson @xerox Is there any possibility to use publicly available nodes or some centralized APIs now? Because if not though necessary functional concerning BitShares will be implement in a Quantum library it will not be used in production on https://cyber.fund and BitShares will be the only without support that is literally bad.
« Last Edit: February 25, 2016, 10:41:43 pm by 21xhipster »
https://cyber.fund/ - Decetnralized Investment Platform

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Hey there,

good to have you on board and your are doing a great job!
I would recommend to take a look into https://github.com/cryptonomex/graphene-ui/tree/master/dl
this directory contains quite a nice amount of coffeescript and es6 code that deals with the bts blockchain.

There is also a python library https://github.com/xeroc/python-graphenelib
and a lot of documentation about the API of BitShares and how to use it:
http://docs.bitshares.org/api

It's late over here and I would leave you with these for now .. If you have more questions, don't hesitate to drop me a line either here or in slack.

Offline besson

  • Newbie
  • *
  • Posts: 1
    • View Profile
Hello bitshares community. Nice to meet you, guys.
I am developer in cyber.fund and now I'm working on crypto-balances library which written with CoffeeScript.
You can easy check addresses balances of various crypto tokens. Script automaticaly recognize a protocol by address and return balance of tokens associated with it.
Library supports following: Bitcoin, Litecoin, Dogecoin, Ethereum, Counterparty, Open Assets, Ripple and IOUs, NXT and NXT AE, NEM, Dash and some other altcoins
In current milestone I'm working on Factom(done), Omni(done) and Bitshares.
I spent a lot of time trying to figure out how bitshares and ecosystem works.
So, I need yours help guys. What I have at this point:
1. Found that bitshares addresses have regex like  BTS[a-zA-Z0-9]{50} (for example BTS7tqXBbtJwDoT8b2LY3kx547ocVfSacTirBMFEsDyhGf2FNR48p)
2. Wrote code for RPC API calls.
3. Started my own node using digital ocean instances for tests.
4. Googled and read bitshares docs and now I'm really confused about bitshares API.
Methods which I found not working and another ones use ids and names, not addresses to return balance.
(blockchain_get_balance, blockchain_list_address_balances, get_account_balances, get_named_account_balances)
Maybe I missed something out, don't know
So, to finish milestone with bitshares integration I need api which can return balance on address and nodes which will return responses.
Sorry for my english guys, I didn't have enough practice. Hope for your help and advices  :)
« Last Edit: February 25, 2016, 09:10:26 pm by besson »