Skip to content

Commit

Permalink
fix: token balance for tron
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhongtao committed Feb 29, 2024
1 parent 2e95664 commit 551a3ee
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions blockchain/chain/tron/tron.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,12 @@ func (t *Tron) GetTokenDecimalsByHttp(host string, token string, contractAddress
func (t *Tron) GetTokenBalanceByHttp2(host string, token string, contractAddress string, userAddress string) (string, error) {

var query string
query = `
{
query = `{
"owner_address": "%v",
"contract_address": "%v",
"function_selector": "balanceOf(address)",
"parameter": "%v"
}
`
"parameter": "%v",
"visible": false}`
var c2 string
if strings.HasPrefix(userAddress, "41") {
c2 = userAddress[2:]
Expand All @@ -212,8 +210,9 @@ func (t *Tron) GetTokenBalanceByHttp2(host string, token string, contractAddress
if err != nil {
return "", err
}
return fmt.Sprintf("%v", b.String()), nil
//balance, _ := strconv.ParseInt(r.Array()[0].String(), 16, 64)
return fmt.Sprintf("%v", b.Int64()), nil
//return fmt.Sprintf("%v", balance), nil
}

return "", errors.New("no data")
Expand Down

0 comments on commit 551a3ee

Please sign in to comment.