美文网首页
在EOSjs查询节点列表,并按照投票数排序

在EOSjs查询节点列表,并按照投票数排序

作者: hbin2018 | 来源:发表于2019-01-03 15:20 被阅读0次

    1.国际惯例 npm install eosjs

    2.建立eosjs与链的连接

    import Eos from 'eosjs'
    
    const eos = Eos({
    
        httpEndpoint: 'https://openapi.eos.ren',
    
        chainId: 0b08e71a2f8caaccc2dc13244b788f5eba29462ecd5d5dea1ad8cbe9581e885a, // 通过eos.getInfo({})可以获取chainId
    
        verbose: false,
    
      });
    
    eos.getTableRows({
    
          "json": true,
    
          "scope": 'eosio',
    
          "code": 'eosio',
    
          "table": "producers",
    
          "key_type":"float64",
    
          "index_position": 'sec',
    
          "limit": 21
    
      }).then((result) => {
    
          console.log(result);
    
      }, this.handleError)
    

    结果:

    image

    总结主要是按照索引排序 index_position 比较难找

    参数说明

    eos.getTableRowscleos get table类型默认值说明

    json-boolfalse设置返回格式是否为 json,如果为 false 则显示原始数据

    codeaccounttext必填合约所在的账号

    scopescopetext必填数据的拥有者,一般和 code/account 一样

    tabletabletext必填表名

    table_key-k,--keytext-要查找的索引名称,已废弃

    lower_bound-L,--lowertext"0"要查找的索引的最小值,默认为第一条数据,包含这个最小值

    upper_bound-U,--uppertext"-1"要查找的索引的最大值,默认为最后一条数据之后,不包含这个最大值

    limit-l,--limituint10返回的数据量,默认为 10

    key_type--key-typestring"i64"索引的数据类型,主键默认为 "i64",支持的其它类型有:i64, i128, i256, float64, float128,name

    index_position--indexTEXT"1"索引的位置,主索引为 1, 第二索引为 2 ,以此类推

    相关文章

      网友评论

          本文标题:在EOSjs查询节点列表,并按照投票数排序

          本文链接:https://www.haomeiwen.com/subject/avgfrqtx.html