Giter Site home page Giter Site logo

Comments (1)

needkane avatar needkane commented on August 27, 2024 1

你可以参照以下文档,不过近期我们打算重构整个RPC

介绍

众安链提供json_rpc 接口

访问json_rpc根路径,可以显示所有接口列表

接口列表

/core_version

查看众安链版本和运行的app版本

  • Method: GET
  • Example
curl http://127.0.0.1:46657/core_version
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        175,
            {
                "version":"f6e19e7d",
                "appname":"",
                "appversion":"alpha 0.2",
                "hash":""
            }
    ],
    "error":""
    
}

/dump_consensus_state

通过当前节点查看共识状态

  • Method: GET

  • Example

curl http://127.0.0.1:46657/dump_consensus_state
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        65,
        {
            "round_state":"RoundState
                    {
                        H:2640 
                        R:0 
                        S:RoundStepNewHeight
                        StartTime:2018-07-16 03:01:09.504559139 -0400 EDT m=+2140.159545756
                        CommitTime:2018-07-16 03:01:08.504559139 -0400 EDT m=+2139.159545756
                        Validators: ValidatorSet
                        {
                            Proposer: Validator
                            {
                                3BEEE425C4A5CE5C82BB33B3768AED456E090A5C 
                                PubKeyEd25519
                                {
                                    3C80281B26B48BB8BD3A24396C090E444616D169C15DDA32CAD7D4AD6E936DB7
                                    
                                } 
                                VP:100 
                                A:0 
                                CA:true
                                
                            }
                            Validators:Validator
                            {
                                3BEEE425C4A5CE5C82BB33B3768AED456E090A5C 
                                PubKeyEd25519
                                {
                                    3C80281B26B48BB8BD3A24396C090E444616D169C15DDA32CAD7D4AD6E936DB7
                                    
                                } 
                                VP:100 
                                A:0 
                                CA:true
                                
                            }
                        }  
                        Proposal:      \u003cnil\u003e\n  
                        ProposalBlock: nil-PartSet nil-Block\n  
                        LockedRound:   0\n  
                        LockedBlock:   nil-PartSet nil-Block\n  
                        Votes:  HeightVoteSet
                        {
                            H:2640 
                            R:0~0\n      
                            VoteSet
                                {
                                    H:2640 
                                    R:0 
                                    T:1 +2/3:\u003cnil\u003e BA
                                        {
                                            1:_
                                            
                                        } 
                                        map[]
                                    
                                }\n      
                            VoteSet
                                {
                                    H:2640 
                                    R:0 
                                    T:2 +2/3:\u003cnil\u003e BA
                                        {
                                            1:_
                                            
                                        } 
                                        map[]
                                    
                                }\n    
                            
                        }\n  
                        LastCommit: VoteSet
                            {
                                H:2639 
                                R:0 T:2 +2/3:63E2F5305DC9A7432F5EB4C3E2957590571BBE90:1:1FAFA258E472 BA
                                    {   
                                        1:X
                                        
                                    } 
                                    map[]
                                
                            }\n  
                            LastValidators:    ValidatorSet
                            {
                                Proposer: Validator
                                {
                                    3BEEE425C4A5CE5C82BB33B3768AED456E090A5C PubKeyEd25519
                                    {
                                        3C80281B26B48BB8BD3A24396C090E444616D169C15DDA32CAD7D4AD6E936DB7
                                        
                                    } 
                                    VP:100 
                                    A:0 
                                    CA:true
                                    
                                }\n      
                                Validators:\n        
                                Validator
                                {
                                    3BEEE425C4A5CE5C82BB33B3768AED456E090A5C PubKeyEd25519
                                    {
                                        3C80281B26B48BB8BD3A24396C090E444616D169C15DDA32CAD7D4AD6E936DB7
                                        
                                    } 
                                    VP:100 
                                    A:0 
                                    CA:true
                                    
                                }\n    
                                
                            }\n
                        
                    }",
                "peer_round_states":[]
            
        }
    ],
    "error":""
    
}

/genesis

查看创世文件内容

  • Method: GET
  • Example
curl http://127.0.0.1:46657/genesis
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        1,
            {
                "genesis":
                {
                    "genesis_time":"2018-07-13T06:44:38.885Z",
                    "chain_id":"rendez-jWjhVn",
                    "validators":[
                        {
                            "pub_key":[
                                1,
                                "3C80281B26B48BB8BD3A24396C090E444616D169C15DDA32CAD7D4AD6E936DB7"
                                ],
                            "amount":100,
                            "name":"",
                            "is_ca":true,
                            "rpc":""
                            
                        }
                    ],
                    "app_hash":"",
                    "plugins":"specialop,querycache"
                    
                }
                
            }
        ],
        "error":""
    
}

/healthinfo

查看当前节点的健康状态

  • Method: GET

  • Response Body

    • status - 200表示正常,非200则异常
  • Example

curl http://127.0.0.1:46657/healthinfo
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        5,
        {
            "status":200
            
        }
    ],
    "error":""
}

/info

获取运行的app相关信息

  • Method: GET
  • Example
curl http://127.0.0.1:46657/info
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        113,
        {
            "data":"default app with evm-1.5.9",
            "version":"alpha 0.2",
            "last_block_height":2160,
            "last_block_app_hash":"56E81F171BCC55A6FF8345E692C0F86E5B48E01B996CADC001622FB5E363B421"
            
        }
    ],
    "error":""
    
}

/last_height

查看节点最新高度

  • Method: GET

  • Example

curl http://127.0.0.1:46657/last_height
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        4,
        {
            "last_height":2273
            
        }
    ],
    "error":""
    
}

/net_info

查看网络信息

  • Method: GET
  • Example
curl http://127.0.0.1:46657/net_info
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        33,
        {
            "listening":true,
            "listeners":[
                "Listener(@192.168.126.215:46656)"
            ],
            "peers":[]
            
        }
    ],
    "error":""
    
}

/num_archived_blocks

查看已归档的数据块个数

  • Method: GET
  • Example
curl http://127.0.0.1:46657/num_archived_blocks
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        100,
        {
            "num":0
            
        }
    ],
    "error":""
    
}

/num_unconfirmed_txs

查看未确认的交易数量

  • Method: GET
  • Example
curl http://127.0.0.1:46657/num_unconfirmed_txs
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        97,
        {
            "n_txs":0,
            "txs":[]
            
        }
    ],
    "error":""
    
}

/status

查看当前链状态,包括节点信息、最新块高度和哈希、运行的app 哈希

  • Method: GET
  • Example
curl http://127.0.0.1:46657/status
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        32,
        {
            "node_info":{
                "pub_key":[
                    1,
                    "3C80281B26B48BB8BD3A24396C090E444616D169C15DDA32CAD7D4AD6E936DB7"
                ],
                "signd_pub_key":"",
                "moniker":"anonymous",
                "network":"rendez-jWjhVn",
                "remote_addr":"tcp://0.0.0.0:46657",
                "listen_addr":"192.168.126.215:46656",
                "version":"0.9.0",
                "other":[
                    "wire_version=0.6.0",
                    "p2p_version=0.3.5",
                    "node_start_at=1531722329","revision=f6e19e7d"
                ]
                
            },
            "pub_key":[
                1,
                "3C80281B26B48BB8BD3A24396C090E444616D169C15DDA32CAD7D4AD6E936DB7"
            ],
            "latest_block_hash":"EF37EB8D5527C2440978D4651A57BB77759BD467",
            "latest_app_hash":"56E81F171BCC55A6FF8345E692C0F86E5B48E01B996CADC001622FB5E363B421",
            "latest_block_height":3388,
            "latest_block_time":1531725230461000000
            
        }
    ],
    "error":""
    
}

/unconfirmed_txs

查看未确认的交易列表

  • Method: GET
  • Example
curl http://127.0.0.1:46657/unconfirmed_txs
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        97,
        {
            "n_txs":0,
            "txs":[]
            
        }
    ],
    "error":""
    
}

/unsafe_flush_mempool

查看刷新mempool后的结果

  • Method: GET
  • Example
curl http://127.0.0.1:46657/unsafe_flush_mempool
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        164,
        {}
    ],
    "error":""
    
}

/validators

查看validator列表

  • Method: GET
  • Example
curl http://127.0.0.1:46657/validators
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        64,
        {
            "block_height":3684,
            "validators":[
                {
                    "address":"3BEEE425C4A5CE5C82BB33B3768AED456E090A5C",
                    "pub_key":[
                        1,
                        "3C80281B26B48BB8BD3A24396C090E444616D169C15DDA32CAD7D4AD6E936DB7"
                    ],
                    "voting_power":100,
                    "accum":0,
                    "is_ca":true
                    
                }
            ]
            
        }
    ],
    "error":""
    
}

/za_surveillance

查看当前链运行状态,包括节点个数、validator个数、运行时长

  • Method: GET
  • Example
curl http://127.0.0.1:46657/za_surveillance
{
    "jsonrpc":"2.0",
    "id":"",
    "result":[
        144,
        {
            "NanoSecsPerTx":0,
            "Height":3813,
            "Addr":"tcp://0.0.0.0:46657",
            "IsValidator":true,
            "NumValidators":1,
            "NumPeers":0,
            "RunningTime":3334,
            "PubKey":"3C80281B26B48BB8BD3A24396C090E444616D169C15DDA32CAD7D4AD6E936DB7"
            
        }
    ],
    "error":""

}

/block?height=[heigth]

通过块高度查看对应块信息

  • Method: GET
  • Request Parameter
    • height:块高度值
  • Example
curl http://127.0.0.1:46657/block?height=6

/blockchain?minHeight=[min]&maxHeight=[max]

查看一定范围内的区块列表

  • Method: GET
  • Request Parameter
    • min:查询范围的最小值
    • max:查询范围的最大值
  • Example
curl http://127.0.0.1:46657/blockchain?minHeight=1&maxHeight=6

/broadcast_tx_async?tx=[tx]

广播异步交易

  • Method: GET

/broadcast_tx_commit

广播同步交易

  • Method: POST
  • Example
curl -X POST -d '
    {
        "jsonrpc":"2.0",
        "id":"",
        "method":"broadcast_tx_commit",
        "params":[
            "F904AE8080843B9ACA008080B9045F608060405233600260006101000A81548173FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF021916908373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16021790555034801561005157600080FD5B5060405160208061043F8339810180604052810190808051906020019092919050505080600160006101000A81548173FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF021916908373FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1602179055505061037A806100C56000396000F300608060405260043610610062576000357C0100000000000000000000000000000000000000000000000000000000900463FFFFFFFF1680631135E96E14610067578063725F4FA7146100BE578063E5841A16146100E9578063FF51AFC914610116575B600080FD5B34801561007357600080FD5B5061007C61016D565B604051808273FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200191505060405180910390F35B3480156100CA57600080FD5B506100D3610197565B6040518082815260200191505060405180910390F35B3480156100F557600080FD5B506101146004803603810190808035906020019092919050505061029A565B005B34801561012257600080FD5B5061012B610346565B604051808273FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16815260200191505060405180910390F35B6000600160009054906101000A900473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF16905090565B6000600160009054906101000A900473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1663E4624D456040518163FFFFFFFF167C0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803B15801561021F57600080FD5B505AF1158015610233573D6000803E3D6000FD5B505050506040513D602081101561024957600080FD5B8101908080519060200190929190505050600081905550600080541415610292577FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6000819055505B600054905090565B600160009054906101000A900473FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1673FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1663F2D9A532826040518263FFFFFFFF167C010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803B15801561032B57600080FD5B505AF115801561033F573D6000803E3D6000FD5B5050505050565B6000339050905600A165627A7A7230582040DFD277CCB2611F09FA2E92AA99AA3F8DF86FCC499CC9070EB568A3B812A7260029000000000000000000000000A8B702CCF5157F7446325A4222A7DD2564D8A5421CA0ECE3EC33698F01E2AA28B6A447F9BD12DAD38F20CC4EA635021473163245E73AA01B696E8DF4DCD371F8F4651DFB8F0FAA8559B9EB57B8C12D26F71F49003B7641"
            ]
        
    }'
    http://127.0.0.1:46657

/query

查看运行的app信息

  • Method: POST
  • Example
curl -X POST -d '{"jsonrpc":"2.0","id":"","method":"query","params":["01F21D46A76D8E4CFC61BE99E58178C6DD17AAF627"]}' http://127.0.0.1:46657
{
    "isSuccess":true,
    "result":"0"
    
}

from annchain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.