Skip to content

Commit

Permalink
use OKLINK key
Browse files Browse the repository at this point in the history
  • Loading branch information
ezynda3 committed Sep 24, 2024
1 parent 988ec87 commit 4e53c70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions apis_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,27 @@ func getCachedABI(
func getAbiFromEtherscan(
chainId, address string,
) (string, []map[string]interface{}, error) {
client := &http.Client{}
apiKey := os.Getenv("CHAIN_" + chainId + "_ETHERSCAN_KEY")
apiUrl := fmt.Sprintf(
"%s?module=contract&action=getsourcecode&address=%s&apikey=%s",
etherscanConfig[chainId],
address,
os.Getenv("CHAIN_"+chainId+"_ETHERSCAN_KEY"),
apiKey,
)
log.Println(apiUrl)

request, err := http.NewRequest(http.MethodGet, apiUrl, nil)
if err != nil {
return "", nil, err
}

if strings.Contains(apiUrl, "oklink") {
request.Header.Add("Ok-Access-Key", apiKey)
}

// Send GET request to Etherscan API
response, err := http.Get(apiUrl)
response, err := client.Do(request)
if err != nil {
return "", nil, err
}
Expand Down

0 comments on commit 4e53c70

Please sign in to comment.