BlockChain區塊鏈
  • 本書簡介
  • 區塊鏈運作原理
  • Bitcoin介紹
    • 簡介
    • Bitcoin其他知識
  • Bitcoin原理與實作
  • BitcoinJS
    • BTC 地址格式種類
    • 從 Mnemonic 轉為地址
  • Serverless 架構實作
  • Docker常用指令
  • ethereum初探
    • ethereum歷史
    • EVM
  • ethereum PoS 節點架設
  • ethereum(Docker)
  • ethereum(Geth)
    • Parity
  • ethereum(智能合約)
    • 合約測試 Unit Test
    • DAO
    • 可升級合約
    • 使用合約進行 multiswap
    • 合約安全
    • 開發工具
    • Hardhat 教學
      • Hardhat 寫測試
    • ERC-721 範例
      • 白名單機制
    • OpenZeppelin 合約 library
    • Truffle
    • 合約部屬
    • solidity 教學
  • ethereum(Dapp)
    • 相關 SDK
    • Multicall
    • Ethers.js 使用
    • Remix IDE
    • web3.js 使用
    • 在網頁上使用 web3 並操作區塊鏈
      • solidity筆記
  • Hyperledger Fabric
  • blockchainDB
  • 挖礦程式使用教學
    • 門羅幣/Monero (XMR)
  • Bitfinex API 使用
  • FTX API
  • CCXT 通用交易所 API
  • Solana 教學
  • Ethereum BigQuery
  • The Graph
    • yaml 定義
    • mapping 語法
    • Schema 定義
    • Query 範例
    • Unit test
  • DeFi 筆記
    • MEV 相關
    • Dex 聚合
    • Yearn
    • Curve
    • Uniswap
      • Swap 互動
    • AAVE、Compound
      • Compound 原理
      • AAVE 合約開發
Powered by GitBook
On this page

Was this helpful?

blockchainDB

PreviousHyperledger FabricNext挖礦程式使用教學

Last updated 3 years ago

Was this helpful?

此為python寫的資料庫,需使用python3來安裝

安裝

安裝相關套件

brew install python3

pip3 install bigchaindb_driver

安裝 libffi/ffi.h  (各平台不同,所以google安裝方法)

pip install --upgrade setuptools

使用docker啟動DB

git clone https://github.com/bigchaindb/bigchaindb-driver.git

cd bigchaindb-driver

$ docker-compose up -d rdb
$ docker-compose up -d bdb-server

把port給出

執行完以下她會給你一個url記得把他填入以下範例程式的連線url

docker-compose port bdb-server 9984

之後試試看如下範例程式,然後使用python test.py執行

test.py

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)

https://docs.bigchaindb.com/projects/py-driver/en/latest/quickstart.html
https://docs.bigchaindb.com/projects/py-driver/en/latest/contributing.html
https://docs.bigchaindb.com/projects/py-driver/en/latest/connect.html