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

单双币流动性质押挖矿系统开发(开发案例)丨子母币流动性质押挖矿系统开发源码版

2023-03-05 18:32 作者:bili_16249894763  | 我要投稿

  Web 3.0:refers to the Internet ecology in the next stage after the mobile Internet,mainly through blockchain and other technical means,to realize the decentralized network form,and to realize the Internet that simulates the real world experience and breaks the virtual and real boundaries;


  Blockchain:a decentralized data structure.Data is stored on distributed nodes,and nodes are computers that provide computing power.They can be personal computers or servers.Both have the nature of both server and client.To modify data,more than half of the nodes are required,which greatly increases the difficulty and security of data modification,thus solving the distrust relationship between people and platforms;


  1.web3连接到区块链的方式


  from web3 import Web3,HTTPProvider,IPCProvider,WebsocketProvider


  """


  HTTPProvider:用于连接基于http和https的JSON-RPC服务器:通过完整的URI找到服务器


  w3=Web3(HTTPProvider


  Web3.IPCProvider用于连接到基于ipc套接字的JSON-RPC服务器:通过文件系统路径找到IPC套接字


  w3=Web3(IPCProvider(参数))开发详细及流程I35案例7O98开发O7I8


  Web3.WebsocketProvider用于连接到基于ws和wss websocket的JSON-RPC服务器:通过完整的URI找到服务器


  w3=Web3(WebsocketProvider


  """


  w3=Web3(HTTPProvider


  print(w3)#<web3.main.Web3 object at 0x105d42510


  from web3 import Web3


  import web3开发设计:MrsFu123


  CONTRACT='0x22C1f6050E56d2876009903609a2cC3fEf83B415'#合约地址


  HTTPProvider="https://dai.poa.network"#主网HttpProvider


  #---打开abi json文件


  with open('contracts/contract_abi.json','r')as contract_abi:


  abi=json.load(contract_abi)


  #---提供HTTPProvider,链上互动的接口


  w3=Web3(Web3.HTTPProvider(HTTPProvider))


  #---检查HTTPProvider


  print(w3.isConnected())


  #Web3.toHex(primary=None,hexstr=None,text=None)


  #接受各种输入并以其十六进制表示形式返回。它遵循JSON-RPC规范


  #def to_hex(


  #primitive:Primitives=None,hexstr:HexStr=None,text:str=None


  #)->HexStr:


  print(Web3.toHex(10))#0xa


  print(Web3.toHex(hexstr='0x00'))#0x00


  print(Web3.toHex(text='asimov'))#0x6173696d6f76


  #Web3.toText(primary=None,hexstr=None,text=None)


  #接受各种输入并返回其等效字符串。文本被解码为UTF-8。


  print(Web3.toText('0x1254'))#T


  print(Web3.toText('0x6173696d6f76'))#asimov


  print(Web3.toText(b'asimx6fx76'))#asimov


  print(Web3.toText('6173696d6f76'))#asimov


  #Web3.toBytes(primary=None,hexstr=None,text=None)


  #接受各种输入并返回等效的字节数。文本被编码为UTF-8。


  print(Web3.toBytes(0))#b'x00'


  print(Web3.toBytes(b'sasas'))#b'sasas'


  print(Web3.toBytes(hexstr='000F'))#b'x00x0f'


  print(Web3.toBytes(hexstr='0x000F'))#b'x00x0f'


  print(Web3.toBytes(text='asimov'))#b'asimov'


  #Web3.toInt(primary=None,hexstr=None,text=None)


  #接受各种输入并返回其等效的整数


  print(Web3.toInt(0))#0


  print(Web3.toInt(0x00f))#15


  print(Web3.toInt(b'x00x0F'))#15


  print(Web3.toInt(hexstr='0x00F'))#15


  #ValueError:invalid literal for int()with base 10:'sa'


  #text:interpret as string of digits,like'12'=>12


  print(Web3.toInt(text='10'))#10


  #Web3.toJSON(obj)obj:Dict[Any,Any]


  #接受各种输入并返回等效的JSON。


  print(Web3.toJSON({'asimov':'da'}))#{"asimov":"da"}


单双币流动性质押挖矿系统开发(开发案例)丨子母币流动性质押挖矿系统开发源码版的评论 (共 条)

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