以太坊 获取合约返回值_从命令行获取以太坊值
以太坊 获取合约返回值
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的值:
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:
由于您购买了带有比特币的以太币,因此获取其比特币价值可能更有价值:
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:
var http = require('http');
http.get({
host: 'coinmarketcap-nexuist.rhcloud.com',
path: '/api/eth'
},
function(response) {
// Continuously update stream with data
var body = '';
response.on('data', function(d) { body += d; });
response.on('end', function() {
// Data reception is done, do whatever with it!
var parsed = JSON.parse(body);
console.log(parsed.price.usd);
});
}
);
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
以太坊 获取合约返回值
还没有评论,来说两句吧...