Files
2204745e34 Add Injective assets (#27191)
* Create logo .png

* Create logo.png

* Create info.json

* Create logo.png

* Create info.json

* Create info.json

* Create logo.png

* Create info.json

* Create logo.png

* Create info.json

* Update info.json

* Update info.json

* Update info.json

* Update info.json

* Update info.json

* Create logo.png

* Delete logo .png

* tokens

* tokens

* tokens

* tokens

* tokens

* tokens

---------

Co-authored-by: Denis <[email protected]>
2024-01-12 15:49:54 +04:00

36 lines
680 B
Go

package external
import (
"fmt"
"strconv"
"github.com/trustwallet/assets-go-libs/http"
)
const ethAPIURL = "https://api.ethplorer.io/getTokenInfo/%s?apiKey=freekey"
type TokenInfoERC20 struct {
Decimals string `json:"decimals"`
HoldersCount int `json:"holdersCount"`
}
func GetTokenInfoForERC20(tokenID string) (*TokenInfo, error) {
url := fmt.Sprintf(ethAPIURL, tokenID)
var result TokenInfoERC20
err := http.GetHTTPResponse(url, &result)
if err != nil {
return nil, err
}
decimals, err := strconv.Atoi(result.Decimals)
if err != nil {
return nil, err
}
return &TokenInfo{
Decimals: decimals,
HoldersCount: result.HoldersCount,
}, nil
}