Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
gmh5225 committed Oct 20, 2024
1 parent 7f8ca86 commit d73b42b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ func main() {
}

func getTokenDecimals(client *ethclient.Client, tokenAddress common.Address) (uint8, error) {
data := []byte{0x67, 0xe5, 0x3c, 0x31} // Correct byte order for "decimals()" function selector
data := []byte{0x31, 0x3c, 0xe5, 0x67} // Correct byte order for "decimals()" function selector
msg := ethereum.CallMsg{To: &tokenAddress, Data: data}
result, err := client.CallContract(context.Background(), msg, nil)
if err != nil {
return 0, err
}
return result[0], nil
return result[len(result)-1], nil // The result is a uint8, padded to 32 bytes, so we take the last byte
}

0 comments on commit d73b42b

Please sign in to comment.