-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcheck_addresses.go
More file actions
49 lines (42 loc) · 1.17 KB
/
check_addresses.go
File metadata and controls
49 lines (42 loc) · 1.17 KB
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
39
40
41
42
43
44
45
46
47
48
49
package examples
import (
"fmt"
"github.com/unpackdev/sourcify-go"
"net/http"
"time"
)
// Example_CheckAddresses demonstrates how to check contract addresses using the Sourcify client.
func Example_CheckAddresses() {
// Create a custom HTTP client with timeout
httpClient := &http.Client{
Timeout: 30 * 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),
),
)
// Define contract addresses to check
contractAddresses := []string{
"0x054B2223509D430269a31De4AE2f335890be5C8F",
}
// Define chain IDs to check
chainIds := []int{
56, // Binance Smart Chain
1, // Ethereum Mainnet
137, // Polygon
}
// Call the API method to check contract addresses
checks, err := sourcify.CheckContractByAddresses(client, contractAddresses, chainIds, sourcify.MethodMatchTypeAny)
if err != nil {
panic(err)
}
// Process the response
for _, check := range checks {
fmt.Printf("Contract Addresses Check Response: %+v\n", check)
}
}