欢迎光临散文网 会员登陆 & 注册

DAPP智能合约互助公排系统开发(开发逻辑)丨DAPP智能合约互助公排开发源码详细

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

  Smart contract is a computer protocol designed to spread,verify or execute contracts in an information-based manner.


  Smart contract is a set of commitments defined in digital form,which control digital assets and contain rights and obligations agreed by contract participants,and is automatically executed by computer system.


  The smart contract program is not only a computer program that can be executed automatically,but also a system participant.It can respond to the received information,receive and store value,and send information and value to the outside


  智能合约的全生命周期包括:合约生成、合约发布和合约执行。


  合约生成:其中合约规范和合约验证至关重要。


  合约发布:需要多个节点进行共识和验证。


  合约执行:基于“事件触发”,智能合约会定期遍历每个合约的状态机和触发条件,将满足触发条件的合约推送到验证队列。


  合约实现:通过赋予对象数字特性,将对象程序化并部署在区块链上,同时改变数字对象的状态(如分配转移)和数值。


  从部署的智能合约中读取数据:


  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']源码案例技术I35流程7O98详细O7I8


  bytecode=truffleFile['bytecode']


  #web3.py instance


  w3=Web3(HTTPProvider("https://ropsten.infura.io/<ApI 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 开发功能:MrsFu123


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


  #Contract instance in concise mode


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


  #Getters+Setters for web3.eth.contract object ConciseContract


  #print(format(contract_instance.getGreeting()))


  print('Contract value:{}'.format(contract_instance.functions.getGreeting().call()))


DAPP智能合约互助公排系统开发(开发逻辑)丨DAPP智能合约互助公排开发源码详细的评论 (共 条)

分享到微博请遵守国家法律