beowulf-python
is the official Beowulf library for Python. It comes with a
BIP38 encrypted wallet and a practical CLI utility called beowulfpy
.
This library currently works on Python 2.7, 3.5 and 3.6. Python 3.3 and 3.4 support forthcoming.
- CHAIN
- get_block
- get_transaction
- TRANSACTION
- broadcast_transaction
- create transaction transfer
- create account
beowulf-python
requires Python 3.5 or higher.- Library dependencies
appdirs
certifi
ecdsa>=0.13
funcy
future
langdetect
prettytable
pycrypto>=1.9.1
pylibscrypt>=1.6.1
scrypt>=0.8.0
toolz
ujson
urllib3
voluptuous
w3lib
On Mac OSX, you may need to do the following first:
brew install openssl
export CFLAGS="-I$(brew --prefix openssl)/include $CFLAGS"
export LDFLAGS="-L$(brew --prefix openssl)/lib $LDFLAGS"
On Ubuntu, Beowulf-python requires libssl-dev
sudo apt-get install libssl-dev
From pip:
pip install beowulf-python
From Source:
git clone https://github.com/beowulf-foundation/beowulf-python.git
cd beowulf-python
python3 setup.py install # python setup.py install for 2.7
or
make install
- Create a new client instance of Beowulfd and add your account to wallet
- Replace nodes with your endpoints which participate to MAINNET or TESTNET chain
Note: Client library will detect MAINNET or TESTNET properties through your provided endpoint.
from beowulf.beowulfd import Beowulfd
from beowulf.commit import Commit
s = Beowulfd(nodes = ['https://testnet-bw.beowulfchain.com/rpc'])
account = "creatorwallet"
c = Commit(beowulfd_instance=s, no_wallet_file=True)
if not c.wallet.getOwnerKeyForAccount(account):
c.wallet.addPrivateKey(pri_key)
# Get block from block number
block_num = 1869
block = c.beowulfd.get_block(block_num)
print(block)
# Get transaction from transaction_id
transaction_id = '45618f73e9dbbe87a9ae6bfc316de8457c502b7c'
trx = c.beowulfd.get_transaction(transaction_id)
print(trx)
# Transfer native coin
asset_bwf = "BWF"
asset_w = "W"
asset_tot = "TOT"
asset_fee = "W"
amount = "1.00000"
fee = "0.01000"
# Transfer BWF from creator to new_account_name
c.transfer(account=creator, amount=amount, asset=asset_bwf, fee=fee, asset_fee=asset_fee, memo="", to=new_account_name)
# Transfer native coin
asset_bwf = "BWF"
asset_w = "W"
asset_tot = "TOT"
asset_fee = "W"
amount = "1.00000"
fee = "0.01000"
# Transfer W from creator to new_account_name
c.transfer(account=creator, amount=amount, asset=asset_w, fee=fee, asset_fee=asset_fee, memo="", to=new_account_name)
# Variances
creator = "creatorwallet"
new_account_name = "newwallet"
new_password_seed = "password_seed"
new_password_wallet = "password_wallet"
# Create account
if not c.beowulfd.get_account(new_account_name):
c.create_account_simple(account_name=new_account_name, creator=creator, password_seed=new_password_seed, password_wallet=new_password_wallet)