以太坊 获取合约返回值_从命令行获取以太坊值

水深无声 2023-02-21 14:29 53阅读 0赞

以太坊 获取合约返回值

Ethereum

Last year I got big into Bitcoin; today I own a few dozen bitcoin and am loving my return. Recently I’ve been hearing big things about Ethereum, another cryptocurrency. Ethereum is in its infancy and has hit some troublesome times recently due to a hack but hey — at its roughly $10 value now, if it ever hits bitcoin-type heights, you could be in for a great return on investment. A while back I wrote a few scripts to get bitcoin value so I thought I’d repeat that post for getting Ether value!

去年,我热衷于比特币。 今天,我拥有几十个比特币,并且热爱我的回报。 最近,我听到了关于另一种加密货币以太坊的大事。 以太坊处于起步阶段,由于黑客攻击,最近遭受了一些麻烦 ,但嘿-以其现在的约10美元的价值,如果它达到了比特币的高度,您可能会获得巨大的投资回报率。 前一阵子我写了一些脚本来获得比特币的价值,所以我想我会重复那篇文章来获得以太币的价值!

从命令行获取以太值 (Get Ether Value from Command Line)

I use a snippet of python to to grab the value of ether from command line:

我使用一小段python从命令行获取ether的值:

  1. curl -s https://coinmarketcap-nexuist.rhcloud.com/api/eth | python -c "import json, sys; print(json.load(sys.stdin)['price']['usd']")

Since you buy ether with bitcoin, getting its bitcoin value may be more of value:

由于您购买了带有比特币的以太币,因此获取其比特币价值可能更有价值:

  1. curl -s https://coinmarketcap-nexuist.rhcloud.com/api/eth | python -c "import json, sys; print(json.load(sys.stdin)['price']['btc'])"

通过Node.js获得任何价值 (Get Either Value with Node.js)

You can use a library like Request for making the API request but to avoid dependency you can use the base Node.js API:

您可以使用诸如Request之类的库来发出API请求,但为避免依赖,可以使用基本的Node.js API:

  1. var http = require('http');
  2. http.get({
  3. host: 'coinmarketcap-nexuist.rhcloud.com',
  4. path: '/api/eth'
  5. },
  6. function(response) {
  7. // Continuously update stream with data
  8. var body = '';
  9. response.on('data', function(d) { body += d; });
  10. response.on('end', function() {
  11. // Data reception is done, do whatever with it!
  12. var parsed = JSON.parse(body);
  13. console.log(parsed.price.usd);
  14. });
  15. }
  16. );

Cryptocurrency lovers will hate on me for talking about bitcoin and ether in terms of USD dollar price but I still see these cryptocurrencies as a short term investment right now. Many online stores don’t accept bitcoin yet so I don’t see a great application right now. Whatever your reason for wanting to know the price of ether, these scripts will be what you need!

加密货币爱好者会讨厌我谈论以美元价格表示的比特币和以太坊,但我现在仍将这些加密货币视为短期投资。 许多在线商店还不接受比特币,所以我现在看不到一个很好的应用程序。 无论您想知道以太币价格的原因是什么,这些脚本都是您所需要的!

翻译自: https://davidwalsh.name/ether-value

以太坊 获取合约返回值

发表评论

表情:
评论列表 (有 0 条评论,53人围观)

还没有评论,来说两句吧...

相关阅读

    相关 智能合约 简介

    以太坊是一个分布式的计算平台。它会生成一个名为Ether的加密货币。程序员可以在以太坊区块链上写下“智能合约”,这些以太坊智能合约会根据代码自动执行。 以太坊是什么?

    相关 智能合约是什么?

    以太坊是最早提出做智能合约的平台。由于以太坊区块链被普遍接受,因此多数区块链的智能合约采取与以太坊相似的设计。本文将详细介绍以太坊的智能合约:它是什么?它有什么用? 以太...