Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw an error in send_commit() #496

Open
piyush4196 opened this issue Jan 16, 2019 · 6 comments
Open

throw an error in send_commit() #496

piyush4196 opened this issue Jan 16, 2019 · 6 comments

Comments

@piyush4196
Copy link

  • 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 :

  1. 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.
@ttmc
Copy link
Contributor

ttmc commented Jan 18, 2019

It seems you're using an old version of BigchainDB Server. Please use the latest version: bigchaindb 2.0.0b9 (Beta 9).

@piyush4196
Copy link
Author

What is the command to upgrade to bigchaindb 2.0.0b9 ? thanks in advance

@ttmc
Copy link
Contributor

ttmc commented Jan 18, 2019

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).

@piyush4196
Copy link
Author

Hey ttmc,

After upgrading the bigchaindb to 2.0.0b9 my bigchaindb is not starting. My steps as :

  1. sudo mongod --replSet=bigchain-rs
    In second terminal
  2. bigchaindb start

thanks!

@ttmc
Copy link
Contributor

ttmc commented Jan 18, 2019

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

@piyush4196
Copy link
Author

piyush4196 commented Feb 8, 2019

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:

  1. mongo
  2. use bigchain;
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants