Files
novatask/internal/job/holder/nft.go
2024-12-27 18:06:13 +08:00

32 lines
807 B
Go

package holder
import (
"encoding/json"
"fmt"
"net/http"
)
type OwnerList struct {
Owners []struct {
OwnerAddress string `json:"ownerAddress"`
TokenBalances []struct {
TokenID string `json:"tokenId"`
Balance string `json:"balance"`
} `json:"tokenBalances"`
} `json:"owners"`
PageKey string `json:"pageKey"`
}
func GetOwnerList() (*OwnerList, error) {
contractAddress := "0x89B8D549feA2eBd2aA0b375ce0DCaBba79e7e636"
url := fmt.Sprintf("https://eth-mainnet.g.alchemy.com/nft/v3/alcht_1a183fAsPqF9upfTfp3AC1l0iedGLo/getOwnersForContract?contractAddress=%s&withTokenBalances=true", contractAddress)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
result := new(OwnerList)
err = json.NewDecoder(resp.Body).Decode(result)
return result, err
}