nft持有查询定时任务
This commit is contained in:
31
internal/job/pledge/nft.go
Normal file
31
internal/job/pledge/nft.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package pledge
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user