Installing Bitcart SDK¶
pip install bitcart
to install the library.
pip install bitcart-async
To install async version of the library.
You can’t install both.
Async version of the library has the same API, but is intended to be used in asyncio application. All is the same, just use async/await. For more details, check async branch README
But to initialize bitcoin instance you will need
rpc_password (not required, defaults
work with default ports and authentification).
For that you’ll need bitcart daemon, so:
git clone https://github.com/MrNaif2018/bitcart cd bitcart pip install -r requirements/base.txt pip install -r requirements/daemons/btc.txt
coin_name refers to coin you’re going to run or use,
COIN_NAME is the same name but in caps.
For example if you run bitcoin,
coin_name=btc, COIN_NAME=BTC, for litecoin
pip install -r requirements/daemons/coin_name.txt to install
requirements for daemon of
This will clone main bitcart repo and install dependencies, we recommend using virtualenv for consistency.(some daemons conflict one with another, so using one virtualenv per daemon is fine).
To run daemon, just start it:
Or, to run it in background(linux only)
python daemons/btc.py &
Note, to run a few daemons, use
python daemons/coin_name.py for each
Default user is electrum and password is electrumz, it runs on http://localhost:5000.
To run daemon in testnet, set
COIN_NAME_TESTNET variable to true.
By default, if coin supports it, lightning network is enabled.
To disable it, set
COIN_NAME_LIGHTNING to false.
For each daemon port is different.
General scheme to get your daemon url is
Where port is the port your daemon uses.
You can change port and host by using
Default ports are starting from 5000 and increase for each daemon by 1
(in order how they were added to bitcart).
Refer to main docs for ports information.
Bitcoin port is 5000, litecoin is 5001, etc.
So, to initialize your bitcart instance right now,
import it and use those settings:
from bitcart.coins.btc import BTC btc = BTC("http://localhost:5000", xpub="your x/y/zpub or x/y/zprv", rpc_user="electrum", rpc_pass="electrumz")
All the variables are actually optional, so you can just do
btc = BTC()
and use it, but without a wallet.
To use a wallet, pass xpub like so:
btc = BTC(xpub="your x/y/zpub or x/y/zprv or electrum seed")
Xpub, xprv or electrum seed is the thing that represents your wallet.
You can get it from your wallet provider, or, for testing or not,
You can configure default user and password in
file of cloned bitcart repo, like so:
After that you can freely use bitcart methods, refer to API docs for more information.