6.3.4 Hyperledger Besu接入说明

  1. 使用Geth控制台与节点进行交互。

  • 示例:

      [root@localhost ~]# geth attach 
      https://admin:123456@bsn91000001.bsngate.com:19602/node1
    
      INFO [07-15|13:41:24.391] Running with private transaction manager disabled - quorum private transactions will not be supported
      WARNING: call to admin.getNodeInfo() failed, unable to determine consensus mechanism
      Welcome to the Geth JavaScript console!
    
      instance: besu/v21.1.2/linux-x86_64/oracle_openjdk-java-11
      coinbase: 0xfd0fdb96a3326c61756711d314bea0149088c3d9
      at block: 195 (Thu Jul 15 2021 13:41:24 GMT+0800 (CST))
      modules: eea:1.0 eth:1.0 ibft:1.0 net:1.0 perm:1.0 priv:1.0 web3:1.0
    
      > web3.eth.blockNumber  
      202
      >
    

  2. 使用JSON-RPC与节点进行交互

  可以使用curl和Postman进行调用。

  • 示例:

       [root@localhost ~]# curl -H "Content-Type: application/json" -d \
       >   '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":2}' \ 
       >  https://admin:123456@bsn91000001.bsngate.com:19602/node1
    
      {
          "jsonrpc":"2.0",
          "id":2,
          "result":"0x365"
      }
    

  3. 使用Web3.js与节点进行交互

  • web3.js类库:https://github.com/ChainSafe/web3.js

  • 示例:

      const Web3 = require("web3");
    
      const web3 = new Web3(
      new Web3.providers.HttpProvider("https://VuF0h0y7pLwtvDqjuW:y2sYuiIciR6JFtHbmC@bsnmu7d0gNn.bsngate.com:19602/node1")
    );
    
      web3.eth.getBlockNumber().then(console.log);
    
Copyright 北京红枣科技有限公司

results matching ""

    No results matching ""

    results matching ""

      No results matching ""