DAPP智慧合約互助公排系統開發邏輯demo

lin199發表於2023-03-14

本文由 威-kaifa873 整理釋出,僅作為專案開發需求參考!飛機@sleu88


從部署的智慧合約中讀取資料:

  import json

  from web3 importWeb3,HTTPProvider

  from web3.contract importConciseContract

  #compile your smart contract with truffle first

  truffleFile=json.load(open('./build/contracts/greeter.json'))

  abi=truffleFile['abi']

  bytecode=truffleFile['bytecode']

  #web3.py instance

  w3=Web3(HTTPProvider(" Key here>"))

  print(w3.isConnected())

  contract_address=Web3.toChecksumAddress("<Deployed Contract Address here>")

  #Instantiate and deploy contract

  contract=w3.eth.contract(abi=abi,bytecode=bytecode)

  #Contract instance 開發功能:kaifa873

  contract_instance=w3.eth.contract(abi=abi,address=contract_address)

  #Contract instance in concise mode



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69988456/viewspace-2939646/,如需轉載,請註明出處,否則將追究法律責任。

相關文章