国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

互助開發(fā)丨互助系統(tǒng)開發(fā)(FDF開發(fā))丨互助源碼模式

2023-02-26 10:29 作者:bili_16249894763  | 我要投稿

  智能合約是部署在區(qū)塊鏈的代碼,區(qū)塊鏈本身不能執(zhí)行代碼,代碼的執(zhí)行是在本地的EVM中,實際上,部署在區(qū)塊鏈上代碼是能夠在本地產(chǎn)生原智能合約代碼的代碼,可以理解區(qū)塊鏈為一個數(shù)據(jù)庫,而客戶端從數(shù)據(jù)庫中讀取了存儲的運行代碼,并在本地運行后,將結果寫入到了區(qū)塊鏈這個數(shù)據(jù)庫中。


  Smart contracts are only programs stored on the blockchain,which will run when the predetermined conditions are met.They are often used to automate the execution of the agreement so that all participants can immediately determine the results without any middleman and without wasting time.They can also automatically complete the workflow and trigger the next operation when the conditions are met.


  在區(qū)塊鏈網(wǎng)絡上部署智能合約


  a)創(chuàng)建項目:


  mkdir pythonDapp


  cd pythonDapp


  truffle init


  成功初始化項目后,轉到您的文件夾并在/contracts目錄中創(chuàng)建greeter.sol文件。在網(wǎng)絡上部署合約之前,我們必須編譯它并構建工件。


  b)智能合約的編譯:開發(fā)方案I35合約7O98系統(tǒng)O7I8


  因此,對于編譯,我們將使用Truffle solc編譯器。在您的主目錄中,運行以下命令:


  truffle compile


  (or)


  truffle.cmd compile#(for windows only)


  上面的命令將在/contracts目錄中編譯你的合約,并在/build目錄中創(chuàng)建二進制工件文件greeter.json。


  c)部署合約:詳細需求:MrsFu123


  打開您的Python IDLE編輯器,并在主目錄deploy.py中使用以下代碼創(chuàng)建一個新文件,然后在您的目錄中運行py deploy.py。


  import json


  from web3 importWeb3,HTTPProvider


  from web3.contract importConciseContract


  #web3.py instance


  w3=Web3(HTTPProvider("https://ropsten.infura.io/v3/<API key>"))


  print(w3.isConnected())


  key="<Private Key here with 0x prefix>"


  acct=w3.eth.account.privateKeyToAccount(key)


  #compile your smart contract with truffle first


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


  abi=truffleFile['abi']


  bytecode=truffleFile['bytecode']


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


  #building transaction


  construct_txn=contract.constructor().buildTransaction({


  'from':acct.address,


  'nonce':w3.eth.getTransactionCount(acct.address),


  'gas':1728712,


  'gasPrice':w3.toWei('21','gwei')})


  signed=acct.signTransaction(construct_txn)


  tx_hash=w3.eth.sendRawTransaction(signed.rawTransaction)


  print(tx_hash.hex())


  tx_receipt=w3.eth.waitForTransactionReceipt(tx_hash)


  print("Contract Deployed At:",tx_receipt['contractAddress'])


互助開發(fā)丨互助系統(tǒng)開發(fā)(FDF開發(fā))丨互助源碼模式的評論 (共 條)

分享到微博請遵守國家法律
灵山县| 双城市| 偃师市| 临夏市| 乌恰县| 巩留县| 丹棱县| 英德市| 奇台县| 凤阳县| 康乐县| 博野县| 广宁县| 和林格尔县| 乌拉特后旗| 宜丰县| 余庆县| 丰镇市| 梁平县| 昌吉市| 华池县| 延寿县| 宁陵县| 晋宁县| 静海县| 铜鼓县| 仙游县| 闵行区| 平潭县| 广州市| 宜昌市| 南江县| 依兰县| 苏州市| 阿尔山市| 寻乌县| 新泰市| 贵溪市| 汝阳县| 广灵县| 盐池县|