-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
example_test.go
36 lines (30 loc) · 1.05 KB
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package tokenbalance
import (
"fmt"
)
var example *TokenBalance
// Create a New Token Balance request with the ERC20 contract address and a wallet address
func ExampleNew() {
token := "0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"
wallet := "0x9ea0c535b3eb166454c8ccbaba86850c8df3ee57"
example, _ = New(token, wallet)
fmt.Printf("This wallet has %v %v tokens", example.BalanceString(), example.Name)
// Output: This wallet has 7.282 StorjToken tokens
}
// View all token information as JSON
func ExampleTokenBalance_ToJSON() {
data := example.ToJSON()
fmt.Println(data)
}
// Return the Token Balance as a string rather than a *big.Int
func ExampleTokenBalance_BalanceString() {
tokens := example.BalanceString()
fmt.Printf("This wallet has %v %v tokens", tokens, example.Name)
// Output: This wallet has 7.282 StorjToken tokens
}
// Return the ETH Balance as a string rather than a *big.Int
func ExampleTokenBalance_ETHString() {
eth := example.ETHString()
fmt.Printf("This wallet has %v ETH", eth)
// Output: This wallet has 0.277525175999999985 ETH
}