标签存档: eos

EOS离线签名

最新版本建议用https://github.com/EOSIO/eosjs-ecc里面的签名函数来处理:

ecc.sign('hello eos', privatekey)

c++实现版本(待验证)

void SignedTransaction::sign(const std::vector<unsigned char> &pri_key, const TypeChainId &cid)
{
    std::vector<unsigned char> packedBytes = getDigestForSignature(cid);

    uint8_t packedSha256[SHA256_DIGEST_LENGTH];
    sha256_Raw(packedBytes.data(), packedBytes.size(), packedSha256);

    uint8_t signature[uECC_BYTES * 2] = { 0 };
    int recId = uECC_sign_forbc(pri_key.data(), packedSha256, signature);
    if (recId == -1) {
        // could not find recid, data probably already signed by the key before?
        return;
    } else {
        unsigned char bin[65+4] = { 0 };
        unsigned char *rmdhash = NULL;
        int binlen = 65+4;
        int headerBytes = recId + 27 + 4;
        bin[0] = (unsigned char)headerBytes;
        memcpy(bin + 1, signature, uECC_BYTES * 2);

        unsigned char temp[67] = { 0 };
        memcpy(temp, bin, 65);
        memcpy(temp + 65, "K1", 2);

        rmdhash = RMD(temp, 67);
        memcpy(bin + 1 +  uECC_BYTES * 2, rmdhash, 4);

        char sigbin[100] = { 0 };
        size_t sigbinlen = 100;
        b58enc(sigbin, &sigbinlen, bin, binlen);
        std::string sig = "SIG_K1_";
        sig += sigbin;

        signatures.push_back(sig);
    }
}

参考:https://github.com/OracleChain/EOSDevHelper.git

eosjs实现版本

/** Sign a transaction */
    public async sign({ chainId, requiredKeys, serializedTransaction }: SignatureProviderArgs) {
        const signBuf = Buffer.concat([
            new Buffer(chainId, "hex"), new Buffer(serializedTransaction), new Buffer(new Uint8Array(32)),
        ]);

        const signatures = requiredKeys.map(
            (pub) => ecc.Signature.sign(signBuf, this.keys.get(convertLegacyPublicKey(pub))).toString(),
        );

       return { signatures, serializedTransaction };

    }

说明:
const test = ecc.Signature.sign(new Buffer("0xa123","hex"),privatekey);
这个得到的就是
"SIG_K1_K9eDsXiqEMkJs8wPwEjiN6hL1h2Bm3gGQtUheidFczWNdBmDF24AUuPmiosi9CwtEW3jPFPao7HYWLJ63ic3TggjnoKtJF"
即离线签名的signatures,有了这个再push_transaction就可以完成交易了

java版本(已验证可用)

https://blog.csdn.net/liu1765686161/article/details/83308819
https://github.com/eosio/eosjs#offline-or-cold-storage-transaction:
https://eosc.app/

https://github.com/EOSIO/eosjs/blob/v16.0.8/src/write-api.js#L498-L510

https://github.com/OracleChain/EOSDevHelper

https://eosfans.io/topics/1176

获取EOS测试账号

endpointlist:https://www.eosdocs.io/resources/apiendpoints/
首先得弄两个eos测试账户,在这个网站上可以弄到,自备梯子
http://jungle.cryptolions.io/#home
点击create account以后出现三个空,第一行是填eos账户名,12位数字字母组合即可,第二行owner public key和第三行active public key怎么填呢?不想写程序的话,就用工具好了:
https://eostea.github.io/eos-generate-key/(推荐)
https://github.com/OracleChain/EOSDevHelper(待验证)
下载对应版本,配置settings,
host: jungle.cryptolions.io port:18888
打开创建账户里面,就自动生成owner public key和active public key
把这两个值拷贝出来到上面的网站里面就生成好了

刚创建的账号是没有测试币的,所以要去http://jungle.cryptolions.io/#home 上面的faucet弄点测试币,依然要梯子过验证,默认一次给100个eos,够用啦

ps:有个问题,工具生成public key,对应的private key怎么从工具里获得,难道就是unlock wallet的key,待后面有时间再验证

~~~~~~~~~~~~~~~~~~~
如何通过私钥生成公钥
源码 : https://github.com/eostea/eos-generate-key
工具 : https://eostea.github.io/eos-generate-key/
原理 : 待续

Postman获取eos账户信息

post访问http://mainnet.eoscanada.com/v1/chain/get_account
或者香港节点
http://api.hkeos.com/v1/chain/get_account
api.hkeos.com
body – raw:

{
"account_name":"eos账户名"
}

response:

{
    "account_name": "amyflashdcom",
    "head_block_num": 23399894,
    "head_block_time": "2018-10-25T05:25:10.000",
    "privileged": false,
    "last_code_update": "1970-01-01T00:00:00.000",
    "created": "2018-07-01T02:41:35.000",
    "core_liquid_balance": "0.0894 EOS",
    "ram_quota": 16653,
    "net_weight": 5100,
    "cpu_weight": 11100,
    "net_limit": {
        "used": 224,
        "available": 343870,
        "max": 344094
    },
    "cpu_limit": {
        "used": 1653,
        "available": 110924,
        "max": 112577
    },
    "ram_usage": 5574,
    "permissions": [
        {
            "perm_name": "active",
            "parent": "owner",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS5jZQnAwNAPsPN9bvT9qGoMVWzbk655bUfVWB73sy2kqTKfWXqa",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        },
        {
            "perm_name": "owner",
            "parent": "",
            "required_auth": {
                "threshold": 1,
                "keys": [
                    {
                        "key": "EOS5jZQnAwNAPsPN9bvT9qGoMVWzbk655bUfVWB73sy2kqTKfWXqa",
                        "weight": 1
                    }
                ],
                "accounts": [],
                "waits": []
            }
        }
    ],
    "total_resources": {
        "owner": "amyflashdcom",
        "net_weight": "0.5100 EOS",
        "cpu_weight": "1.1100 EOS",
        "ram_bytes": 15253
    },
    "self_delegated_bandwidth": {
        "from": "amyflashdcom",
        "to": "amyflashdcom",
        "net_weight": "0.5100 EOS",
        "cpu_weight": "1.1100 EOS"
    },
    "refund_request": null,
    "voter_info": {
        "owner": "amyflashdcom",
        "proxy": "",
        "producers": [
            "bitfinexeos1",
            "eos42freedom",
            "eosauthority",
            "eosbeijingbp",
            "eosbixinboot",
            "eoscafeblock",
            "eoscanadacom",
            "eoscannonchn",
            "eoscybexiobp",
            "eosfishrocks",
            "eosflytomars",
            "eoshuobipool",
            "eosiomeetone",
            "eosiosg11111",
            "eosisgravity",
            "eoslaomaocom",
            "eosnationftw",
            "eosnewyorkio",
            "helloeoscnbp",
            "jedaaaaaaaaa",
            "oraclegogogo",
            "starteosiobp",
            "zbeosbp11111"
        ],
        "staked": 16200,
        "last_vote_weight": "7634359820.36285972595214844",
        "proxied_vote_weight": "0.00000000000000000",
        "is_proxy": 0
    }
}

获取eos可用余额

post请求
http://mainnet.eoscanada.com/v1/chain/get_currency_balance
参数body-raw

{"code":"eosio.token", "account":"amyflashdcom", "symbol":"eos"}

response:

[
    "0.0894 EOS"
]

连接到21个eos节点的方法

1.命令行连接

Download EOS docker image

docker pull eosio/eos-dev

Run keosd tool in docker

docker run –rm –name eosio -d -v ~/eosio-wallet:/root/eosio-wallet eosio/eos-dev /bin/bash -c ‘keosd’

Create an alias for convenience

alias cleos=’docker exec -i eosio /opt/eosio/bin/cleos –wallet-url http://localhost:8888 -u https://api.eosnewyork.io:443′

备注:可用的endpoints列表https://www.eosdocs.io/resources/apiendpoints/

国内用这个http://api.hkeos.com:80 比较快

测试是否成功:cleos get info ,出现下面这个就算成功,yeap

 {
      "server_version": "0f6695cb",
      "chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
      "head_block_num": 21514477,
      "last_irreversible_block_num": 21514147,
      "last_irreversible_block_id": "014847a335b78279d795fca1361031d61dbbb123be1554532aa6f335c65268ec",
      "head_block_id": "014848edaceb16b5b24417f62ecd641bb8c568173908a5b08c13ade63e7df9c7",
      "head_block_time": "2018-10-14T07:16:02.500",
      "head_block_producer": "eosfishrocks",
      "virtual_block_cpu_limit": 35430525,
      "virtual_block_net_limit": 1048576000,
      "block_cpu_limit": 190087,
      "block_net_limit": 1047336,
      "server_version_string": "v1.3.0"
    }

ps:网上好多教程都是教怎么搭建本地节点的,但是需要很多服务器资源,以后再折腾

关闭某个占用端口的进程

以下命令可用于杀死占用某端口的所有进程。
kill -9 $(lsof -i tcp:进程号 -t)
另外,非root用户可能需要执行
kill -9 $(sudo lsof -i tcp:进程号 -t)
补充:
查看某端口占用情况
lsof -i :端口号

2 eosjs连接

npm install eosjs

然后保存下面这个代码为1.js,执行node 1.js,开启http://localhost:8080/
就可以看到最近的生产区块的节点和信息,其他api参考https://github.com/EOSIO/eosjs-api/blob/master/src/api/v1/chain.json
api参数说明:
http://blog.hubwiz.com/2018/09/15/EOS-eosjs-use/
https://github.com/eoshackathon/eos_dapp_development_cn/blob/master/docs/eosjs_manual.md

var http = require('http');

http.createServer(function (request, response) {
    // 发送 HTTP 头部 
    // HTTP 状态值: 200 : OK
    // 内容类型: text/plain
    response.writeHead(200, {'Content-Type': 'text/plain'});
const Eos = require('eosjs');

const eos = Eos({httpEndpoint: "http://api.hkeos.com:80"});
//const eos = Eos();  
  // 发送响应数据 "Hello World"
const eos2 = eos.getInfo((error, info) => {
   // console.log(error, info);
response.end(JSON.stringify(info,null,2));
});

//  response.end(JSON.stringify(eos2,null,2));
}).listen(8080);

获取账户可用余额

var http = require('http');

http.createServer(function (request, response) {
    // 发送 HTTP 头部 
    // HTTP 状态值: 200 : OK
    // 内容类型: text/plain
    response.writeHead(200, {'Content-Type': 'text/plain'});
const Eos = require('eosjs');

const eos = Eos({httpEndpoint: "http://api.hkeos.com:80"});
//const eos = Eos();  
  // 发送响应数据 "Hello World"
const eos2 = eos.getInfo((error, info) => {
   // console.log(error, info);
//response.end(JSON.stringify(info,null,2));
});
var test=eos.getCurrencyBalance({ code: "eosio.token", account: "amyflashdcom", symbol: "EOS" }).then(result =>
//console.log(result);
//  response.end(JSON.stringify(test,null,2));
response.end(JSON.stringify(result))
);
}).listen(8080);

// 终端打印如下信息
console.log('Server running at http://127.0.0.1:8080/');

EOS开发资源清单

EOS开发资源清单

原文:
https://steemit.com/eos/@eostribe/the-big-list-of-eos-developer-resources
作者:EOS Tribe(@sf2)
https://medium.com/coinmonks/getting-started-with-eosjs-6be29dbb71be

235.https://hackernoon.com/getting-started-on-eos-mainnet-in-10-minutes-bf61dd9ec787:

236.https://github.com/slowmist/eos-smart-contract-security-best-practices

237.https://dfuse.io/
eos资讯社区:
https://www.shensi.com/#/eos
eos白皮书:
https://github.com/EOSLaoMao/Documentation/blob/master/zh-CN/TechnicalWhitePaper-v2.md

荆凯整理的表格版本
https://shimo.im/sheet/Zo2uVm3u6hE485dC/RIDOC/

虽然EOS主网推出仅3个多月,但是EOS的用户和开发者社区正迅速增长。

在撰写本文时,EOS已经达到了2000多万个不可逆转的区块,并且最高每秒处理的事务达到3996个(TPS)。

更令人印象深刻的是不断增长的活跃用户群。截至目前,前10名的EOS dApp拥有超过24,822个活跃用户,是以太坊上前10大dApp的活跃用户量的4倍。(来源: https://dappradar.com/eos-dapps )。

对我们的前90天来说还不错!

EOS dApp开发资源
我们的工作还没有完成,才刚刚开始。本周,我们在Denver(丹佛)举办了第一个EOS开发者研讨会——EOS Rise。我们希望创建一个有用的资源库,开发者可以参考这些资源来找到所有与EOS dApp开发相关的最新工具、插件和库。

我们知道一切都是分散的,特别是在早期,但是情况正一点一点地、一点一点地好转。

所以没有更多的麻烦…这里是我们的EOS开发资源的大清单……

开发者频道
EOS的优势之一是,它是一个了不起的开发者社区。永远不要因为需要寻求帮助而感到羞愧。你会发现在下面的任何一个频道中都有大量的EOS开发人员,他们知识渊博并乐于帮助您解决问题。你要做的第一件事就是用Telegram(电报),因为你会经常用到它。

1、 EOS Developers(Telegram)
这是目前EOS开发人员的主要中心,仅面向EOS开发讨论(是的,仅!)。您的任何问题可以获得其他社区成员以及Block One员工回答。众所周知,Dan Larimer本人会不时出现在这个小组中回答问题。

链接 – https://t.me/joinchat/Esi1OkPktgcFeJ3Lmlcrqg

2、EOS Rise (Telegram)

EOS Rise Developer Workshop系列的官方小组。你可以找到Phil Mesnier,Eugene Luzgin和其他导师,他们很乐意回答你的任何技术问题。

链接 – https://t.me/eosrise

3、 EOS Opportunities (Telegram)
在EOS中讨论机会,宣传您的技能,与DAPP公司联系,在EOS经济中找到您的定位。

链接 – https://t.me/eos_opportunities

4、 EOS Design (Telegram)

任何与UX/UI或一般设计主题相关的内容。如果你更关注前端,你经常可以从社区中找到其他设计师来合作。

链接 – https://t.me/EOSdesign

开发文档和工具
您需要好的文档和工具来构建杀手级dApp,这正是我们为您提供来自EOS生态系统的最佳开发文档和工具的原因。

5、 EOSIO Developer Portal

由Block One自己构建的EOSIO Developer门户,是获得有关EOSIO软件最新版本最新信息的最佳场所之一。

链接 – https://developers.eos.io

6、EOSIO Stack Exchange

如有疑问,去 Stack Exchange 。EOSIO Stack Exchange活跃于来自世界各地的知识渊博的开发人员。如果您刚开始,绝对是一个关键资源。

链接 – https://eosio.stackexchange.com

7、EOSDocs
EOSDocs是另一个开发文档和资源的好地方。

链接 – https://www.eosdocs.io

8、EOS Bootcamp
大量的区块生产者(节点)赞助的课程和教育资源。

链接 – https://eosbootcamp.com

9、 EOS Tutorials
各种技能水平的EOS教程网站。

链接 – https://eostutorials.com

10、CLEOS
命令行界面,用于与区块链交互并管理钱包。

链接 – https://github.com/EOSIO/eos/tree/master/programs/cleos

11、 NODEOS
EOSIO核心节点守护进程,可以配置插件来运行节点。示例用途是区块生产,专用API端点和本地开发。

链接 – https://github.com/EOSIO/eos/tree/master/programs/nodeos

12、 KEOSD
将EOSIO密钥安全存储在钱包中的组件。

链接 – https://github.com/EOSIO/eos/tree/master/programs/keosd

13、EOSC
EOSC是一个跨平台(Windows,Mac和Linux)命令行工具。

链接 – https://github.com/eoscanada/eosc

14、FC
FC表示快速编译的c++库,并提供了一组实用程序库,可用于异步库的开发。

链接 – https://github.com/bytemaster/fc

15、Wabt
WABT(我们将其命名为“wabbit”)是WebAssembly的一套工具。

链接 – https://github.com/WebAssembly/wabt

16、Wasm Dec
WASMDEC是一个将WebAssembly二进制文件转换为C的程序。

链接 – https://github.com/wwwg/wasmdec

17、 EOSIO Contracts
包含EOSIO一些基本功能的智能合约

链接 – https://github.com/EOSIO/eosio.contracts

18、EOS Smart Contract Development Toolkit
Dockerized环境,以引导您的智能合约开发。

链接 – https://github.com/EOSArgentina/eosdev

19、 EOS Factory
基于Python的EOS智能合约开发和测试框架。

链接 – https://github.com/tokenika/eosfactory

20、EOSJS
EOS区块链的通用JS库。

链接 – https://github.com/EOSIO/eosjs

21、 EOSJS Browser
适用于浏览器的EOSJS版本。

链接 – https://github.com/EveripediaNetwork/eosjs-browser

22、EOSIO Project Boilerplate Simple
一个EOSIO样板项目,包含UI和Smart Contract代码,以及初始化和启动所有必要组件以帮助您开始构建的设置脚本。

链接 – https://github.com/EOSIO/eosio-project-boilerplate-simple

23、EOS RC Parser
EOS Ricardian合约解析器。

链接 – https://github.com/EOSEssentials/EOS-RC-Parser

24、 EOS Helpers
帮助EOSIO的bash脚本列表。

链接 – https://github.com/EOSEssentials/EOSHelpers

25、EOS Blox
EOS Blox是世界上第一套Web组件,并提供定制的智能合约。

链接 – https://www.eosblox.com/

26、Ping EOS
在EOS / React.js之间实现ping。

链接 – https://github.com/eosasia/ping-eos

27、EOS Encrypt
允许加密和解密消息。

链接 – https://github.com/EOS-Nation/eos-encrypt

28、EOS Communication
此node.js模块允许在EOS平台上进行链上加密通信。

链接 – https://github.com/eostitan/eos-communication

29、Bloks.io
EOS最好的区块链浏览器之一。在跟踪网络上的所有类型的操作时非常好用。

链接 – https://bloks.io

测试网
您应该做的第一件事就是参与EOS testnet,以便开始测试您的dApp。EOS的两个主要测试网络是Jungle和Cryptokylin。我们建议开发人员熟悉这两种tesnet环境。

30、Jungle
Jungle是生态系统中最久,最可靠的测试网之一,已成为EOS开发社区的支柱。

链接 – https://github.com/CryptoLions/EOS-Jungle-Testnet

31、 Cryptokylin
CryptoKylin Testnet是一个开发人员友好的测试网络,主要由位于中国的一群EOS 主网节点维护,但世界各地都有积极的参与者。

链接 – https://github.com/cryptokylin/CryptoKylin-Testnet

32、EOS Debug
EOS Debug是帮助EOS开发人员在社区测试网上下载、构建和试验EOS.IO软件的指南。

链接 – https://github.com/eoscafe/eos-debug

基础设施/ DevOps
如果没有一些基本的DevOps技能以及修复节点常见问题的能力,您将无法开发EOS dApp。我们在这篇文章中收集了一些最好的资源,让你的工作更轻松。

33、EOS Node Tools

适用于任何EOS爱好者、dApp开发人员或区块生产者的资源和工具集合。
链接 – https://eosnode.tools

34、 EOSIO Docker
在Docker上简单快速地设置EOS.IO。

链接 – https://github.com/EOSIO/eos/tree/master/Docker

35、EOS Test Cave
EOS验证的自动化测试框架。

链接 – https://github.com/EOS-BP-Developers/EOS-Test-Cave

36、EOSIO AWS Kinesis插件
Amazon Kinesis使收集、处理和分析实时流数据变得更加容易,因此你可以获得及时的见解,并对新信息做出快速反应。如果你在使用AWS的话,EOSIO AWS Kinesis插件可以让设置变得更容易一些。

链接 – https://github.com/eosasia/nodeos_kinesis_plugin

37、EOS Web Sockets
你的dApp需要一些 web sockets吗?使用它为EOS创建 web sockets。

链接 – https://github.com/EOS-Nation/eosws

38、 PatronEOS
用于EOS节点的RPC检查点。

链接 – https://github.com/EOSIO/patroneos

39、 Pitreos
EOS的时间点恢复,发音类似于“Patriots”。

链接 – https://github.com/eoscanada/pitreos

40、Demux
区块链应用程序的确定性事件源状态和副作用处理。

链接 – https://github.com/EOSIO/demux-js

41、Incoming Transfer Rules
在EOS上,传入传输可以应用规则。

链接 – https://github.com/eosauthority/incoming-transfer-rules

42、 EOS Node Watcher
观察和过滤EOS节点事务/操作并推送到RabbitMQ,MongoDB,0MQ等。

链接 – https://github.com/EOSEssentials/eos-node-watcher

43、 EOSIO GraphQL
为EOSIO区块链部署GraphQL API + MongoDB。

链接 – https://github.com/EOS-BP-Developers/eosio-graphql

44、 EOSIO MongoDB查询
快速为EOSIO区块链创建复杂的MongoDB查询。

链接 – https://github.com/EOS-BP-Developers/eosio-mongodb-queries

45、 EOS RabitMQ插件
一个EOS RabbitMQ插件,让您的生活更轻松。

链接 – https://github.com/bancorprotocol/eos-rabbitmq-plugin

46、EOS ZeroMQ插件
这个插件与history_plugin大致相同,但不是将历史事件存储在共享内存数据库中,而是通过ZeroMQ PUSH socket将它们推送到nodeos进程之外

链接 – https://github.com/cc32d9/eos_zmq_plugin

47、EOS ZeroMQ Receiver
这是一组脚本,用于接收和处理由nodeos ZeroMQ插件生成的数据流。

链接 – https://github.com/cc32d9/eos_zmq_plugin_receiver/

48、 EOSIO Kaftka插件
Kafka用于构建实时数据管道和流媒体应用程序,此插件允许您利用EOS区块链利用Kaftka丰富的所有实时功能。

链接 – https://github.com/TP-Lab/kafka_plugin

49、 EOS Mechanics
EOS Mechanics基准合约和公用工具。

链接 – https://github.com/AlohaEOS/eos-mechanics

Wrappers, API 和 SDK
不会用C ++编写?没关系,每天都有针对您选择语言的EOSIO软件包装和SDK。这里有一些目前可用的。
50、 EOS Scala Wrapper
EOS RPC API的Scala wrapper 。

链接 – https://github.com/EOSEssentials/Scala-API-Wrapper

51、 EOS Java Wrapper
EOS RPC调用的Java实现。

链接 – https://github.com/EOSEssentials/eos-java-rpc-wrapper

52、 EOS Go
EOSIO Go API库。

链接 – https://github.com/eoscanada/eos-go

53、EOSpy
该库仍在进行中,但目前能够在不编译代码的情况下执行所有cleos get函数。

链接 – https://github.com/eosnewyork/eospy

54、EOS Sharp
EOS区块链的C#客户端库。

链接 – https://github.com/GetScatter/eos-sharp

55、 EOS PHP
适用于EOS API的PHP Wrapper。

链接 – https://github.com/kesar/eos-php

56、 PHP EOS RPC SDK
适用于EOS RPC API的PHP SDK。

链接 – https://github.com/BlockMatrixNetwork/php-eos-rpc-sdk

57、 EOS API Service
EOS API服务平台。

链接 – https://github.com/Tandemly/eos-api-service

结论
即使EOSIO是如此的新,但你已经拥有了丰富的资源来快速启动和运行你的项目。