goplus-sdk-go

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2023 License: MIT

README

GoPlus API SDK for Go

Installation
go get github.com/GoPlusSecurity/goplus-sdk-go
Get AccessToken

key := ""
secret := ""
app := auth.NewApp(key, secret, nil)
data, err := app.GetAccessToken()

if err != nil {
    panic(err.Error())
}

if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}

accessToken := data.Result.AccessToken
Get Supported Blockchains
accessToken := ""
chain := NewChain(accessToken, nil)
data, err := chain.Run("")

if err != nil {
    panic(err)
}
if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}

Token Security

accessToken := ""
tokenSecurity := token.NewTokenSecurity(accessToken, &Config{
    Timeout: 10, // you can set timeout seconds
})
chainId := "1"
contractAddresses := []string{"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}
data, err := tokenSecurity.Run(chainId, contractAddresses)
if err != nil {
    panic(err)
}
if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}
value, ok := data.Result["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"]

if ok {
    fmt.Printf("%v", value["token_symbol"])
}

Address Security

accessToken := ""
addressSecurity := address.NewAddressSecurity(accessToken, nil)
data, err := addressSecurity.Run("", "0xc8b759860149542a98a3eb57c14aadf59d6d89b9")
if err != nil {
    panic(err)
}
if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}

fmt.Printf("%v", data.Result["data_source"])
Approval Security API v1

accessToken := ""
approvalSecurityV1 := approval.NewApprovalSecurity(accessToken, nil)
data, err := approvalSecurityV1.Run("1", "0x4639cd8cd52ec1cf2e496a606ce28d8afb1c792f")

if err != nil {
    panic(err)
}

if data.Code != errorcode.SUCCESS && data.Code != errorcode.DATA_PENDING_SYNC {
    panic(data.Message)
}

fmt.Printf("%v", data.Result["contract_name"])

Approval Security API v2
Token Approval Security

accessToken := ""
approvalSecurityV2 := approval.NewApprovalSecurityV2(accessToken, nil)
data, err := approvalSecurityV2.Token("56", "0xd018e2b543a2669410537f96293590138cacedf3")
if err != nil {
    panic(err)
}
if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}

fmt.Printf("%v", data.Result[0]["token_address"])

ERC721 NFT Approval Security
accessToken := ""
approvalSecurityV2 := approval.NewApprovalSecurityV2(accessToken, nil)
data, err := approvalSecurityV2.ERC721NFT("1", "0xd95dbdab08a9fed2d71ac9c3028aac40905d8cf3")
if err != nil {
    panic(err)
}
if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}

fmt.Printf("%v", data.Result[0]["nft_address"])
ERC1155 NFT Approval Security

accessToken := ""
approvalSecurityV2 := approval.NewApprovalSecurityV2(accessToken, nil)
data, err := approvalSecurityV2.ERC1155NFT("56", "0xb0dccbb9c4a65a94a41a0165aaea79c8b2fc54ce")
if err != nil {
    panic(err)
}
if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}

fmt.Printf("%v", data.Result[0]["nft_address"])
Signature Data Decode
accessToken := ""
signatureDataDecode := decode.NewSignatureDataDecode(accessToken, nil)

chainId := "1"
contractAddress := "0x4cc8aa0c6ffbe18534584da9b592aa438733ee66"
inputData := "0xa0712d680000000000000000000000000000000000000000000000000000000062fee481"
data, err := signatureDataDecode.Run(chainId, contractAddress, inputData)
if err != nil {
    panic(err)
}
if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}

fmt.Printf("%v", data.Result[""])
NFT Security

accessToken := ""
nftSecurity := nft.NewNFTSecurity(accessToken, nil)

chainId := "1"
contractAddress := "0x82f5ef9ddc3d231962ba57a9c2ebb307dc8d26c2"
data, err := nftSecurity.Run(chainId, contractAddress)

if err != nil {
    panic(err)
}

if data.Code != errorcode.SUCCESS && data.Code != errorcode.DATA_PENDING_SYNC {
    panic(data.Message)
}

fmt.Printf("%v", data.Result["nft_address"])
dApp Security Info API
accessToken := ""
dAppSecurity := dapp.NewDAppSecurity(accessToken, nil)

url := "https://for.tube"
data, err := dAppSecurity.Run(url)

if err != nil {
    panic(err)
}

if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}

fmt.Printf("%v", data.Result["project_name"])
Phishing Site Detection API
accessToken := ""
phishingSiteSecurity := phishing_site.NewPhishingSiteDetection(accessToken, nil)

url := "https://xn--cm-68s.cc/"
data, err := phishingSiteSecurity.Run(url)

if err != nil {
    panic(err)
}

if data.Code != errorcode.SUCCESS {
    panic(data.Message)
}

fmt.Printf("%v", data.Result["phishing_site"])
	

Directories

Path Synopsis
api
nft
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL