-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_all_addresses.go
38 lines (32 loc) · 1.01 KB
/
get_all_addresses.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
37
38
package examples
import (
"fmt"
"github.com/unpackdev/sourcify-go"
"net/http"
"time"
)
// Example_GetAllAddresses demonstrates how to retrieve all available contract addresses using the Sourcify client.
func Example_GetAllAddresses() {
// Create a custom HTTP client with timeout
httpClient := &http.Client{
Timeout: 10 * time.Second,
}
// Create a new Sourcify client with custom options
client := sourcify.NewClient(
sourcify.WithHTTPClient(httpClient),
sourcify.WithBaseURL("https://sourcify.dev/server"),
sourcify.WithRetryOptions(
sourcify.WithMaxRetries(3),
sourcify.WithDelay(2*time.Second),
),
)
// Call the API method to retrieve all available contract addresses
addresses, err := sourcify.GetAvailableContractAddresses(client, 56)
if err != nil {
panic(err)
}
// Print the number of full match addresses
fmt.Printf("Full Match Addresses: %d\n", len(addresses.Full))
// Print the number of partial match addresses
fmt.Printf("Partial Match Addresses: %d\n\n", len(addresses.Partial))
}