![TokenBalance](http://i.imgur.com/43Blvht.jpg)
# TokenBalance API [![Build Status](https://travis-ci.org/hunterlong/tokenbalance.svg?branch=master)](https://travis-ci.org/hunterlong/tokenbalance) [![Docker Build Status](https://img.shields.io/docker/build/hunterlong/tokenbalance.svg)](https://hub.docker.com/r/hunterlong/tokenbalance/) [![Coverage Status](https://coveralls.io/repos/github/hunterlong/tokenbalance/badge.svg?branch=master)](https://coveralls.io/github/hunterlong/tokenbalance?branch=master) [![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/hunterlong/tokenbalance)
TokenBalance is an easy to use public API and application that will output your [ERC20 Token](https://github.com/ConsenSys/Tokens/blob/master/Token_Contracts/contracts/Token.sol) balance without any troubles. You can run TokenBalance on your local computer or you can use api.tokenbalance.com to easily parse your erc20 token balances.
Connects to your local geth IPC and prints out a simple JSON response for ethereum token balances. Runs on port *8080* by default if you wish to run locally.
<p align="center">
<a href="https://github.com/hunterlong/balancebadge"><img src="https://img.balancebadge.io/eth/0x004F3E7fFA2F06EA78e14ED2B13E87d710e8013F.svg?color=green"></a> <a href="https://github.com/hunterlong/balancebadge"><img src="https://img.balancebadge.io/token/0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0/0x3bf19a5b8b8cacda07c0ad46c18b27d999c15d0f.svg?color=purple"></a> <a href="https://github.com/hunterlong/balancebadge"><img src="https://img.balancebadge.io/token/0xd26114cd6EE289AccF82350c8d8487fedB8A0C07/0x12a99eb147af05a68ff900d8e9f55d855a41dda7.svg?color=cyan"></a> <a href="https://github.com/hunterlong/balancebadge"><img src="https://img.balancebadge.io/token/0xe41d2489571d322189246dafa5ebde1f4699f498/0xb15bb8a5c133aeb874c2b61252b7f01128574332.svg?color=red"></a>
</p>
## Server Status and Uptime
You can view the current status of Token Balance along with API latency information on our status page. This status page logs the Ethereum Mainnet, Ropsten testnet, and Rinkeby testnet.
[https://status.tokenbalance.com](https://status.tokenbalance.com)
## Installing Token Balance
You don't need to compile Token Balance from source anymore! All you need to do is go to [Releases](https://github.com/hunterlong/tokenbalance/releases/latest) in this repo and download the binary that is built for your OS.
Once you've downloaded, rename the file to `tokenbalance` for ease if use. On Mac or Linux move this file with the command `mv tokenbalance /usr/local/bin/tokenbalance`, you should be able to run the application from anywhere now.
## Token Balance and Token Info (/token)
To fetch information about your balance, token details, and ETH balance use the follow API call in a simple HTTP GET or CURL. The response is in JSON so you can easily parse what you need. Replace TOKEN_ADDRESS with the contract address of the ERC20 token, and replace ETH_ADDRESS with your address.
###### Ethereum Mainnet
```bash
https://api.tokenbalance.com/token/TOKEN_ADDRESS/ETH_ADDRESS
```
###### Ethereum Ropsten Testnet
```bash
https://test.tokenbalance.com/token/TOKEN_ADDRESS/ETH_ADDRESS
```
###### Ethereum Rinkeby Testnet
```bash
https://rinkeby.tokenbalance.com/token/TOKEN_ADDRESS/ETH_ADDRESS
```
- ###### Response (JSON)
```bash
{
"name": "Kin",
"wallet": "0x393c82c7Ae55B48775f4eCcd2523450d291f2418",
"symbol": "KIN",
"decimals": 18,
"balance": "15788648",
"eth_balance": "0.217960852347180212",
"block": 4274167
}
```
## Only Token Balance (/balance)
This API response will only show you the ERC20 token balance in plain text. Perfect for ultra simple parsing.
```bash
https://api.tokenbalance.com/balance/TOKEN_ADDRESS/ETH_ADDRESS
```
- ###### Response (PLAIN TEXT)
```bash
1022.503000
```
## Examples
- [jsFiddle AJAX Example](https://jsfiddle.net/hunterlong/nkqr6064/)
- [Fetch Balance and Token Details for Status Coin](https://api.tokenbalance.com/token/0x744d70FDBE2Ba4CF95131626614a1763DF805B9E/0x242f3f8cffecc870bdb30165a0cb3c1f06f32949)
- [Fetch Balance and Token Details for Gnosis](https://api.tokenbalance.com/token/0x6810e776880c02933d47db1b9fc05908e5386b96/0x97b47ffde901107303a53630d28105c6a7af1c3e)
- [Fetch Balance and Token Details for Storj](https://api.tokenbalance.com/token/0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac/0x29b532092fd5031b9ee1e5fe07d627abedd5eda8)
- [Only Token Balance for Augur](https://api.tokenbalance.com/balance/0x48c80F1f4D53D5951e5D5438B54Cba84f29F32a5/0x90fbfc09db2f4b6e8b65b7a237e15bba9dc5db0c)
- [Only Token Balance for Golem](https://api.tokenbalance.com/balance/0xa74476443119A942dE498590Fe1f2454d7D4aC0d/0xe42b94dc4b02edef833556ede32757cf2b6cc455)
# Run with Docker
You can easily start [Token Balance with Docker](https://hub.docker.com/r/hunterlong/tokenbalance/builds/). Register for a free [Infura.io API Key](https://infura.io/signup) to use Token Balance without downloading the ethereum blockchain.
```
docker run -p 8080:8080 -e GETH_SERVER=https://mainnet.infura.io/APIKEY -d hunterlong/tokenbalance
```
# Use as Golang Package
You can use Token Balance as a typical Go Language package if you you like to implement ERC20 functionality into your own application.
```bash
go get github.com/hunterlong/tokenbalance
```
###### First you'll want to connect to your Geth server or IPC
```go
import (
"github.com/hunterlong/tokenbalance"
)
func main() {
// connect to your Geth Server
configs = &tokenbalance.Config{
GethLocation: "https://eth.coinapp.io",
Logs: true,
}
configs.Connect()
// insert a Token Contract address and Wallet address
contract := "0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0"
wallet := "0xbfaa1a1ea534d35199e84859975648b59880f639"
// query the blockchain and wallet details
token, err := tokenbalance.New(contract, wallet)
// Token Balance will respond back useful things
token.BalanceString() // "600000.0"
token.ETHString() // "1.020095885777777767"
token.Name // "OmiseGO"
token.Symbol // "OMG"
token.Decimals // 18
token.Balance // big.Int() (token balance)
token.ETH // big.Int() (ether balance)
}
```
# Implement in Google Sheets
If your familiar with Google Sheets, you can easily fetch all of your cryptocurrency balances within 1 spreadsheet. All you need to do is make a cell with the value below.
```
=ImportData("https://api.tokenbalance.com/balance/0xd26114cd6EE289AccF82350c8d8487fedB8A0C07/0xf9578adc61d07671f536d50afc5800232fc9fd86")
```
Simple as that! Get creative an use Coin Market Cap's API to fetch the price and multiply with your balance to make a portfolio of your cryptocurrencies!
# Implement in your App
Feel free to use the TokenBalance API server to fetch ERC20 token balances and details. We do have a header set that will allow you to call the API via AJAX. `Access-Control-Allow-Origin "*"` The server may limit your requests if you do more than 60 hits per minute.
# Run Your Own Server
TokenBalance isn't just an API, it's an opensource HTTP server that you can run on your own computer or server.
<p align="center"><img width="85%" src="https://img.cjx.io/tokenbalanceunix.gif">
<img width="85%" src="https://img.cjx.io/tokenbalancewindows.gif">
</p>
## Installation
##### Ubuntu 16.04
```bash
git clone https://github.com/hunterlong/tokenbalance
cd tokenbalance
go get && go build ./cmd
```
## Start TokenBalance Server
```bash
tokenbalance start --geth="/ethereum/geth.ipc"
```
This will create a light weight HTTP server will respond balance information about a ethereum contract token.
## Optional Config
```bash
tokenbalance start --geth="/ethereum/geth.ipc" --port 8080 --ip 127.0.0.1
```
#### CURL Request
```bash
CONTRACT=0xa74476443119A942dE498590Fe1f2454d7D4aC0d
ETH_ADDRESS=0xda0aed568d9a2dbdcbafc1576fedc633d28eee9a
curl ht
没有合适的资源?快使用搜索试试~ 我知道了~
tokenbalance:简单的以太坊API,以获取您的ERC20代币余额以及有用的信息
共58个文件
png:26个
go:9个
html:3个
1星 需积分: 50 17 下载量 182 浏览量
2021-02-05
05:12:29
上传
评论 2
收藏 571KB ZIP 举报
温馨提示
TokenBalance API TokenBalance是易于使用的公共API和应用程序,可以毫无困难地输出您的余额。 您可以在本地计算机上运行TokenBalance,也可以使用api.tokenbalance.com轻松解析erc20令牌余额。 连接到您的本地geth IPC并为以太坊令牌余额打印出一个简单的JSON响应。 如果您希望在本地运行,则默认情况下在端口8080上运行。 服务器状态和正常运行时间 您可以在我们的状态页面上查看令牌余额的当前状态以及API延迟信息。 此状态页面记录以太坊主网,Ropsten测试网和Rinkeby测试网。 安装令牌余额 您不再需要从源代码编译令牌余
资源详情
资源评论
资源推荐
收起资源包目录
tokenbalance-master.zip (58个子文件)
tokenbalance-master
Gopkg.toml 925B
.gitignore 30B
Dockerfile 1KB
doc.go 1KB
Makefile 4KB
.dockerignore 34B
.travis.yml 1KB
tokenbalance_test.go 3KB
LICENSE 11KB
.github
FUNDING.yml 71B
tokens.go 9KB
example_test.go 1KB
README.md 8KB
tokenbalance.go 4KB
Gopkg.lock 7KB
types.go 694B
docs
images
lgheader.jpg 115KB
screen1.png 115KB
website.png 258KB
google0f62af282d497ce8.html 53B
robots.txt 24B
browserconfig.xml 281B
sitemap.xml 597B
css
narrow.css 2KB
ror.rss 588B
README.md 712B
index.html 19KB
manifest.json 775B
documentation.html 11KB
favicons
favicon-32x32.png 2KB
apple-icon.png 6KB
favicon-16x16.png 1KB
apple-icon-precomposed.png 6KB
apple-icon-152x152.png 5KB
ms-icon-144x144.png 5KB
apple-icon-60x60.png 2KB
ms-icon-310x310.png 14KB
ms-icon-70x70.png 3KB
apple-icon-144x144.png 5KB
apple-icon-72x72.png 3KB
android-icon-192x192.png 6KB
android-icon-36x36.png 2KB
apple-icon-120x120.png 4KB
android-icon-96x96.png 3KB
favicon-96x96.png 3KB
android-icon-72x72.png 3KB
apple-icon-76x76.png 3KB
favicon.ico 1KB
android-icon-144x144.png 5KB
android-icon-48x48.png 2KB
apple-icon-114x114.png 4KB
apple-icon-57x57.png 2KB
apple-icon-180x180.png 7KB
ms-icon-150x150.png 5KB
CNAME 16B
cmd
server.go 2KB
server_test.go 5KB
main.go 2KB
共 58 条
- 1
XanaHopper
- 粉丝: 34
- 资源: 4725
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1