bigchaindb-driver
bigchaindb-driver copied to clipboard
throw an error in send_commit()
- bigchaindb-driver version: 0.6.2
- bigchaindb server version (
bigchaindb -v
): 1.3.0 - Python version:3.6.7
- Operating System: Ubuntu 18.04
Description
I have successfully installed the bigchaindb and its running in the http://localhost:9984/ I can see the welcome json. I am trying to do my first transaction on which I am getting an error
My python script is :
`from bigchaindb_driver import BigchainDB bdb_root_url = 'http://localhost:9984' bdb = BigchainDB(bdb_root_url)
generate a keypair
from bigchaindb_driver.crypto import generate_keypair alice, bob = generate_keypair(), generate_keypair()
create a digital asset for Alice
game_boy_token = { 'data': { 'token_for': { 'game_boy': { 'serial_number': 'LR35902' } }, 'description': 'Time share token. Each token equals one hour of usage.', }, }
prepare the transaction with the digital asset and issue 10 tokens for Bob
prepared_token_tx = bdb.transactions.prepare( operation='CREATE', signers=alice.public_key, recipients=[([bob.public_key], 10)], asset=game_boy_token)
fulfill and send the transaction
fulfilled_token_tx = bdb.transactions.fulfill( prepared_token_tx, private_keys=alice.private_key)
print(fulfilled_token_tx) bdb.transactions.send_commit(fulfilled_token_tx)`
In send_commit I am getting an error :
{'inputs': [{'owners_before': ['ZmVkNrqgMZUnXcXwoKRfXAQnvxGu2gcyh1CSqjpvdq2'], 'fulfills': None, 'fulfillment': 'pGSAIAhk5bSEJPVfzb6eu_eHz81xTguBvUpLfpmMAgV96S3pgUAHfLVHjqXvSYSFGf1k4fe_kA9-EnufjWojyZhWtkKZnptCWYmrXYLtlPjwi0LSKP7PGL2NK9GHvhpjPPDajkYA'}], 'outputs': [{'public_keys': ['3ePfKBgYWiZev8U8zMUkkoT3bNNUgEa17cVQTuk6Yvdf'], 'condition': {'details': {'type': 'ed25519-sha-256', 'public_key': '3ePfKBgYWiZev8U8zMUkkoT3bNNUgEa17cVQTuk6Yvdf'}, 'uri': 'ni:///sha-256;SE7SFxLL_aMud6haTniv4VxhUBtG52lsQfyKihTEomQ?fpt=ed25519-sha-256&cost=131072'}, 'amount': '10'}], 'operation': 'CREATE', 'metadata': None, 'asset': {'data': {'token_for': {'game_boy': {'serial_number': 'LR35902'}}, 'description': 'Time share token. Each token equals one hour of usage.'}}, 'version': '2.0', 'id': '8f1a51ea1a78285ae8223af31607781a99c09098991ba618b6ef1746da40b907'} Traceback (most recent call last): File "Desktop/blockchain_bc/index.py", line 35, in
bdb.transactions.send_commit(fulfilled_token_tx) File "/home/piyush/.local/lib/python3.6/site-packages/bigchaindb_driver/driver.py", line 375, in send_commit headers=headers) File "/home/piyush/.local/lib/python3.6/site-packages/bigchaindb_driver/transport.py", line 82, in forward_request backoff_cap=backoff_cap, File "/home/piyush/.local/lib/python3.6/site-packages/bigchaindb_driver/connection.py", line 91, in request **kwargs, File "/home/piyush/.local/lib/python3.6/site-packages/bigchaindb_driver/connection.py", line 128, in _request raise exc_cls(response.status_code, text, json, kwargs['url']) bigchaindb_driver.exceptions.BadRequest: (400, '{"message":"Invalid transaction schema: '2.0' does not match '^1\\\\.0$'","status":400}\n', {'message': "Invalid transaction schema: '2.0' does not match '^1\\.0$'", 'status': 400}, 'http://localhost:9984/api/v1/transactions/')
I would like to point few things :
- I have installed in bigchaindb in my localsystem and there is no other node connected.
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
It seems you're using an old version of BigchainDB Server. Please use the latest version: bigchaindb 2.0.0b9 (Beta 9).
What is the command to upgrade to bigchaindb 2.0.0b9 ? thanks in advance
Something like:
sudo pip3 install --upgrade bigchaindb==2.0.0b9
or just sudo pip install ...
if pip means the Python 3 version of pip in your current Python environment (or virtual environment).
Hey ttmc,
After upgrading the bigchaindb to 2.0.0b9 my bigchaindb is not starting. My steps as :
- sudo mongod --replSet=bigchain-rs In second terminal
- bigchaindb start
thanks!
If you installed MongoDB on Ubuntu 18.04 using sudo apt install mongodb
, then it should already be running; you don't have to start it. You might have to clear out its BigchainDB tables though, i.e. to get everything back to a clean state. You can do that using bigchaindb drop
. You also need to run Tendermint.
In general, just see the Simple Deployment Template at:
http://docs.bigchaindb.com/projects/server/en/latest/simple-deployment-template/index.html
Hello Troy,
I have followed all the steps which is mentioned in the template above. I have installed the bigchaindb in two machine in VirtualBox with the IP : XXX.XX.XX.92:9984 and XXX.XX.XX.93:9984. I am able to access both IP and in the third machine I am getting the welcome json of BigchainDb. And genesis.json is same in both the machine and in config.toml I have changes which is asked in the template. When I ran my script to Create assets I can view in only one machine not in second machine. Can you please help me out here.
I am viewing my assets my the command:
- mongo
- use bigchain;
- db.assets.find();
My script is 👍
`from bigchaindb_driver import BigchainDB bdb_root_url = 'http://XXX.XX.XX.92:9984' bdb = BigchainDB(bdb_root_url)
from bigchaindb_driver.crypto import generate_keypair alice, bob = generate_keypair(), generate_keypair()
game_boy_token = { 'data': { 'token_for': { 'game_boy': { 'serial_number': 'LR35902' } }, 'description': 'Time share token. Each token equals one hour of usage.', }, }
prepared_token_tx = bdb.transactions.prepare( operation='CREATE', signers=alice.public_key, recipients=[([bob.public_key], 10)], asset=game_boy_token)
fulfilled_token_tx = bdb.transactions.fulfill( prepared_token_tx, private_keys=alice.private_key) bdb.transactions.send_commit(fulfilled_token_tx)
transfer_asset = {'id': fulfilled_token_tx['id']} output_index = 0 output = fulfilled_token_tx['outputs'][output_index] transfer_input = {'fulfillment': output['condition']['details'], 'fulfills': {'output_index': output_index, 'transaction_id': transfer_asset['id']}, 'owners_before': output['public_keys']}
prepared_transfer_tx = bdb.transactions.prepare( operation='TRANSFER', asset=transfer_asset, inputs=transfer_input, recipients=[([alice.public_key], 3), ([bob.public_key], 7)])
fulfilled_transfer_tx = bdb.transactions.fulfill( prepared_transfer_tx, private_keys=bob.private_key) sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)`
FYI : I am looking for shared assets rather then transferring assets: For ex: If Node 1 create asset it will be shared with the all other nodes which is connected. Please help me here which points i have missed or I am doing something wrong.