brew install python3
pip3 install bigchaindb_driver
安裝 libffi/ffi.h (各平台不同,所以google安裝方法)
pip install --upgrade setuptools
git clone https://github.com/bigchaindb/bigchaindb-driver.git
cd bigchaindb-driver
$ docker-compose up -d rdb
$ docker-compose up -d bdb-server
docker-compose port bdb-server 9984
from bigchaindb_driver import BigchainDB
from bigchaindb_driver.crypto import generate_keypair
bdb = BigchainDB('http://0.0.0.0:32773')
bicycle = {
'data': {
'bicycle': {
'serial_number': 'abcd1234',
'manufacturer': 'bkfab',
},
},
}
metadata = {'planet': 'earth'}
alice, bob = generate_keypair(), generate_keypair()
prepared_creation_tx = bdb.transactions.prepare(
operation='CREATE',
signers=alice.public_key,
asset=bicycle,
metadata=metadata,
)
fulfilled_creation_tx = bdb.transactions.fulfill(prepared_creation_tx, private_keys=alice.private_key)
print(fulfilled_creation_tx)
sent_creation_tx = bdb.transactions.send(fulfilled_creation_tx)