blockaidclientgo

package module
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

Blockaid Go API Library

Go Reference

The Blockaid Go library provides convenient access to the Blockaid REST API from applications written in Go. The full API of this library can be found in api.md.

It is generated with Stainless.

Installation

import (
	"github.com/blockaid-official/blockaid-client-go" // imported as blockaidclientgo
)

Or to pin the version:

go get -u 'github.com/blockaid-official/blockaid-client-go@v0.9.2'

Requirements

This library requires Go 1.18+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/blockaid-official/blockaid-client-go"
	"github.com/blockaid-official/blockaid-client-go/option"
)

func main() {
	client := blockaidclientgo.NewClient(
		option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("BLOCKAID_CLIENT_API_KEY")
	)
	transactionScanResponse, err := client.Evm.JsonRpc.Scan(context.TODO(), blockaidclientgo.EvmJsonRpcScanParams{
		Chain: blockaidclientgo.F(blockaidclientgo.TransactionScanSupportedChainEthereum),
		Data: blockaidclientgo.F(blockaidclientgo.EvmJsonRpcScanParamsData{
			Method: blockaidclientgo.F("eth_signTypedData_v4"),
			Params: blockaidclientgo.F([]interface{}{"0x49c73c9d361c04769a452E85D343b41aC38e0EE4", "{\"domain\":{\"chainId\":1,\"name\":\"Aave interest bearing WETH\",\"version\":\"1\",\"verifyingContract\":\"0x030ba81f1c18d280636f32af80b9aad02cf0854e\"},\"message\":{\"owner\":\"0x49c73c9d361c04769a452E85D343b41aC38e0EE4\",\"spender\":\"0xa74cbd5b80f73b5950768c8dc467f1c6307c00fd\",\"value\":\"115792089237316195423570985008687907853269984665640564039457584007913129639935\",\"nonce\":\"0\",\"deadline\":\"1988064000\",\"holder\":\"0x49c73c9d361c04769a452E85D343b41aC38e0EE4\"},\"primaryType\":\"Permit\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Permit\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"deadline\",\"type\":\"uint256\"}]}}"}),
		}),
		Metadata: blockaidclientgo.F(blockaidclientgo.MetadataParam{
			Domain: blockaidclientgo.F("https://boredapeyartclub.com"),
		}),
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", transactionScanResponse.Validation)
}

Request fields

All request parameters are wrapped in a generic Field type, which we use to distinguish zero values from null or omitted fields.

This prevents accidentally sending a zero value if you forget a required parameter, and enables explicitly sending null, false, '', or 0 on optional parameters. Any field not specified is not sent.

To construct fields with values, use the helpers String(), Int(), Float(), or most commonly, the generic F[T](). To send a null, use Null[T](), and to send a nonconforming value, use Raw[T](any). For example:

params := FooParams{
	Name: blockaidclientgo.F("hello"),

	// Explicitly send `"description": null`
	Description: blockaidclientgo.Null[string](),

	Point: blockaidclientgo.F(blockaidclientgo.Point{
		X: blockaidclientgo.Int(0),
		Y: blockaidclientgo.Int(1),

		// In cases where the API specifies a given type,
		// but you want to send something else, use `Raw`:
		Z: blockaidclientgo.Raw[int64](0.01), // sends a float
	}),
}
Response objects

All fields in response structs are value types (not pointers or wrappers).

If a given field is null, not present, or invalid, the corresponding field will simply be its zero value.

All response structs also include a special JSON field, containing more detailed information about each property, which you can use like so:

if res.Name == "" {
	// true if `"name"` is either not present or explicitly null
	res.JSON.Name.IsNull()

	// true if the `"name"` key was not present in the repsonse JSON at all
	res.JSON.Name.IsMissing()

	// When the API returns data that cannot be coerced to the expected type:
	if res.JSON.Name.IsInvalid() {
		raw := res.JSON.Name.Raw()

		legacyName := struct{
			First string `json:"first"`
			Last  string `json:"last"`
		}{}
		json.Unmarshal([]byte(raw), &legacyName)
		name = legacyName.First + " " + legacyName.Last
	}
}

These .JSON structs also include an Extras map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := blockaidclientgo.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Evm.JsonRpc.Scan(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

Errors

When the API returns a non-success status code, we return an error with type *blockaidclientgo.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Evm.JsonRpc.Scan(context.TODO(), blockaidclientgo.EvmJsonRpcScanParams{
	Chain: blockaidclientgo.F(blockaidclientgo.TransactionScanSupportedChainEthereum),
	Data: blockaidclientgo.F(blockaidclientgo.EvmJsonRpcScanParamsData{
		Method: blockaidclientgo.F("eth_signTypedData_v4"),
		Params: blockaidclientgo.F([]interface{}{"0x49c73c9d361c04769a452E85D343b41aC38e0EE4", "{\"domain\":{\"chainId\":1,\"name\":\"Aave interest bearing WETH\",\"version\":\"1\",\"verifyingContract\":\"0x030ba81f1c18d280636f32af80b9aad02cf0854e\"},\"message\":{\"owner\":\"0x49c73c9d361c04769a452E85D343b41aC38e0EE4\",\"spender\":\"0xa74cbd5b80f73b5950768c8dc467f1c6307c00fd\",\"value\":\"115792089237316195423570985008687907853269984665640564039457584007913129639935\",\"nonce\":\"0\",\"deadline\":\"1988064000\",\"holder\":\"0x49c73c9d361c04769a452E85D343b41aC38e0EE4\"},\"primaryType\":\"Permit\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Permit\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"deadline\",\"type\":\"uint256\"}]}}"}),
	}),
	Metadata: blockaidclientgo.F(blockaidclientgo.MetadataParam{
		Domain: blockaidclientgo.F("https://boredapeyartclub.com"),
	}),
})
if err != nil {
	var apierr *blockaidclientgo.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/v0/evm/json-rpc/scan": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Evm.JsonRpc.Scan(
	ctx,
	blockaidclientgo.EvmJsonRpcScanParams{
		Chain: blockaidclientgo.F(blockaidclientgo.TransactionScanSupportedChainEthereum),
		Data: blockaidclientgo.F(blockaidclientgo.EvmJsonRpcScanParamsData{
			Method: blockaidclientgo.F("eth_signTypedData_v4"),
			Params: blockaidclientgo.F([]interface{}{"0x49c73c9d361c04769a452E85D343b41aC38e0EE4", "{\"domain\":{\"chainId\":1,\"name\":\"Aave interest bearing WETH\",\"version\":\"1\",\"verifyingContract\":\"0x030ba81f1c18d280636f32af80b9aad02cf0854e\"},\"message\":{\"owner\":\"0x49c73c9d361c04769a452E85D343b41aC38e0EE4\",\"spender\":\"0xa74cbd5b80f73b5950768c8dc467f1c6307c00fd\",\"value\":\"115792089237316195423570985008687907853269984665640564039457584007913129639935\",\"nonce\":\"0\",\"deadline\":\"1988064000\",\"holder\":\"0x49c73c9d361c04769a452E85D343b41aC38e0EE4\"},\"primaryType\":\"Permit\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Permit\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"deadline\",\"type\":\"uint256\"}]}}"}),
		}),
		Metadata: blockaidclientgo.F(blockaidclientgo.MetadataParam{
			Domain: blockaidclientgo.F("https://boredapeyartclub.com"),
		}),
	},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as param.Field[io.Reader]. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper blockaidclientgo.FileParam(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := blockaidclientgo.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Evm.JsonRpc.Scan(
	context.TODO(),
	blockaidclientgo.EvmJsonRpcScanParams{
		Chain: blockaidclientgo.F(blockaidclientgo.TransactionScanSupportedChainEthereum),
		Data: blockaidclientgo.F(blockaidclientgo.EvmJsonRpcScanParamsData{
			Method: blockaidclientgo.F("eth_signTypedData_v4"),
			Params: blockaidclientgo.F([]interface{}{"0x49c73c9d361c04769a452E85D343b41aC38e0EE4", "{\"domain\":{\"chainId\":1,\"name\":\"Aave interest bearing WETH\",\"version\":\"1\",\"verifyingContract\":\"0x030ba81f1c18d280636f32af80b9aad02cf0854e\"},\"message\":{\"owner\":\"0x49c73c9d361c04769a452E85D343b41aC38e0EE4\",\"spender\":\"0xa74cbd5b80f73b5950768c8dc467f1c6307c00fd\",\"value\":\"115792089237316195423570985008687907853269984665640564039457584007913129639935\",\"nonce\":\"0\",\"deadline\":\"1988064000\",\"holder\":\"0x49c73c9d361c04769a452E85D343b41aC38e0EE4\"},\"primaryType\":\"Permit\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"Permit\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"deadline\",\"type\":\"uint256\"}]}}"}),
		}),
		Metadata: blockaidclientgo.F(blockaidclientgo.MetadataParam{
			Domain: blockaidclientgo.F("https://boredapeyartclub.com"),
		}),
	},
	option.WithMaxRetries(5),
)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]interface{}

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   blockaidclientgo.F("id_xxxx"),
    Data: blockaidclientgo.F(FooNewParamsData{
        FirstName: blockaidclientgo.F("John"),
    }),
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := blockaidclientgo.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals).
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(value bool) param.Field[bool]

Bool is a param field helper which helps specify bools.

func F

func F[T any](value T) param.Field[T]

F is a param field helper used to initialize a param.Field generic struct. This helps specify null, zero values, and overrides, as well as normal values. You can read more about this in our README.

func FileParam

func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader]

FileParam is a param field helper which helps files with a mime content-type.

func Float

func Float(value float64) param.Field[float64]

Float is a param field helper which helps specify floats.

func Int

func Int(value int64) param.Field[int64]

Int is a param field helper which helps specify integers. This is particularly helpful when specifying integer constants for fields.

func Null

func Null[T any]() param.Field[T]

Null is a param field helper which explicitly sends null to the API.

func Raw

func Raw[T any](value any) param.Field[T]

Raw is a param field helper for specifying values for fields when the type you are looking to send is different from the type that is specified in the SDK. For example, if the type of the field is an integer, but you want to send a float, you could do that by setting the corresponding field with Raw[int](0.5).

func String

func String(value string) param.Field[string]

String is a param field helper which helps specify strings.

Types

type AddressAssetExposure

type AddressAssetExposure struct {
	// description of the asset for the current diff
	Asset AddressAssetExposureAsset `json:"asset,required"`
	// dictionary of spender addresses where the exposure has changed during this
	// transaction for the current address and asset
	Spenders map[string]AddressAssetExposureSpender `json:"spenders,required"`
	JSON     addressAssetExposureJSON               `json:"-"`
}

func (*AddressAssetExposure) UnmarshalJSON

func (r *AddressAssetExposure) UnmarshalJSON(data []byte) (err error)

type AddressAssetExposureAsset

type AddressAssetExposureAsset struct {
	// string represents the name of the asset
	Name string `json:"name"`
	// asset's symbol name
	Symbol string `json:"symbol"`
	// address of the token
	Address string `json:"address,required"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// asset type.
	Type AddressAssetExposureAssetType `json:"type,required"`
	// asset's decimals
	Decimals int64                         `json:"decimals"`
	JSON     addressAssetExposureAssetJSON `json:"-"`
	// contains filtered or unexported fields
}

description of the asset for the current diff

func (AddressAssetExposureAsset) AsUnion

func (*AddressAssetExposureAsset) UnmarshalJSON

func (r *AddressAssetExposureAsset) UnmarshalJSON(data []byte) (err error)

type AddressAssetExposureAssetType

type AddressAssetExposureAssetType string

asset type.

const (
	AddressAssetExposureAssetTypeErc20   AddressAssetExposureAssetType = "ERC20"
	AddressAssetExposureAssetTypeErc1155 AddressAssetExposureAssetType = "ERC1155"
	AddressAssetExposureAssetTypeErc721  AddressAssetExposureAssetType = "ERC721"
	AddressAssetExposureAssetTypeNonerc  AddressAssetExposureAssetType = "NONERC"
)

func (AddressAssetExposureAssetType) IsKnown

func (r AddressAssetExposureAssetType) IsKnown() bool

type AddressAssetExposureAssetUnion

type AddressAssetExposureAssetUnion interface {
	// contains filtered or unexported methods
}

description of the asset for the current diff

Union satisfied by Erc20TokenDetails, Erc1155TokenDetails, Erc721TokenDetails or NonercTokenDetails.

type AddressAssetExposureSpender

type AddressAssetExposureSpender struct {
	Exposure interface{} `json:"exposure"`
	// user friendly description of the approval
	Summary string `json:"summary"`
	// the amount that was asked in the approval request for this spender from the
	// current address and asset
	Approval int64 `json:"approval"`
	// the expiration time of the permit2 protocol
	Expiration time.Time `json:"expiration" format:"date-time"`
	// boolean indicates whether an is_approved_for_all function was used (missing in
	// case of ERC20 / ERC1155)
	IsApprovedForAll bool                            `json:"is_approved_for_all"`
	JSON             addressAssetExposureSpenderJSON `json:"-"`
	// contains filtered or unexported fields
}

func (AddressAssetExposureSpender) AsUnion

func (*AddressAssetExposureSpender) UnmarshalJSON

func (r *AddressAssetExposureSpender) UnmarshalJSON(data []byte) (err error)

type AddressAssetExposureSpendersUnion

type AddressAssetExposureSpendersUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by Erc20Exposure, Erc721Exposure or Erc1155Exposure.

type AssetDiff added in v0.7.3

type AssetDiff struct {
	// description of the asset for the current diff
	Asset AssetDiffAsset `json:"asset,required"`
	// amount of the asset that was transferred to the address in this transaction
	In []AssetDiffIn `json:"in,required"`
	// amount of the asset that was transferred from the address in this transaction
	Out  []AssetDiffOut `json:"out,required"`
	JSON assetDiffJSON  `json:"-"`
}

func (*AssetDiff) UnmarshalJSON added in v0.7.3

func (r *AssetDiff) UnmarshalJSON(data []byte) (err error)

type AssetDiffAsset added in v0.7.3

type AssetDiffAsset struct {
	// string represents the name of the asset
	Name string `json:"name"`
	// asset's symbol name
	Symbol string `json:"symbol"`
	// address of the token
	Address string `json:"address"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// asset type.
	Type AssetDiffAssetType `json:"type,required"`
	// asset's decimals
	Decimals  int64              `json:"decimals"`
	ChainName string             `json:"chain_name"`
	ChainID   int64              `json:"chain_id"`
	JSON      assetDiffAssetJSON `json:"-"`
	// contains filtered or unexported fields
}

description of the asset for the current diff

func (AssetDiffAsset) AsUnion added in v0.7.3

func (r AssetDiffAsset) AsUnion() AssetDiffAssetUnion

func (*AssetDiffAsset) UnmarshalJSON added in v0.7.3

func (r *AssetDiffAsset) UnmarshalJSON(data []byte) (err error)

type AssetDiffAssetType added in v0.7.3

type AssetDiffAssetType string

asset type.

const (
	AssetDiffAssetTypeErc20   AssetDiffAssetType = "ERC20"
	AssetDiffAssetTypeErc1155 AssetDiffAssetType = "ERC1155"
	AssetDiffAssetTypeErc721  AssetDiffAssetType = "ERC721"
	AssetDiffAssetTypeNonerc  AssetDiffAssetType = "NONERC"
	AssetDiffAssetTypeNative  AssetDiffAssetType = "NATIVE"
)

func (AssetDiffAssetType) IsKnown added in v0.7.3

func (r AssetDiffAssetType) IsKnown() bool

type AssetDiffAssetUnion added in v0.7.3

type AssetDiffAssetUnion interface {
	// contains filtered or unexported methods
}

description of the asset for the current diff

Union satisfied by Erc20TokenDetails, Erc1155TokenDetails, Erc721TokenDetails, NonercTokenDetails or NativeAssetDetails.

type AssetDiffIn added in v0.7.3

type AssetDiffIn struct {
	// usd equal of the asset that was transferred from this address
	UsdPrice string `json:"usd_price"`
	// user friendly description of the asset transfer
	Summary string `json:"summary"`
	// id of the token
	TokenID int64 `json:"token_id"`
	// value before divided by decimal, that was transferred from this address
	Value string `json:"value"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// value before divided by decimal, that was transferred from this address
	RawValue string          `json:"raw_value"`
	JSON     assetDiffInJSON `json:"-"`
	// contains filtered or unexported fields
}

func (AssetDiffIn) AsUnion added in v0.7.3

func (r AssetDiffIn) AsUnion() AssetDiffInUnion

func (*AssetDiffIn) UnmarshalJSON added in v0.7.3

func (r *AssetDiffIn) UnmarshalJSON(data []byte) (err error)

type AssetDiffInUnion added in v0.7.3

type AssetDiffInUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by Erc1155Diff, Erc721Diff, Erc20Diff or NativeDiff.

type AssetDiffOut added in v0.7.3

type AssetDiffOut struct {
	// usd equal of the asset that was transferred from this address
	UsdPrice string `json:"usd_price"`
	// user friendly description of the asset transfer
	Summary string `json:"summary"`
	// id of the token
	TokenID int64 `json:"token_id"`
	// value before divided by decimal, that was transferred from this address
	Value string `json:"value"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// value before divided by decimal, that was transferred from this address
	RawValue string           `json:"raw_value"`
	JSON     assetDiffOutJSON `json:"-"`
	// contains filtered or unexported fields
}

func (AssetDiffOut) AsUnion added in v0.7.3

func (r AssetDiffOut) AsUnion() AssetDiffOutUnion

func (*AssetDiffOut) UnmarshalJSON added in v0.7.3

func (r *AssetDiffOut) UnmarshalJSON(data []byte) (err error)

type AssetDiffOutUnion added in v0.7.3

type AssetDiffOutUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by Erc1155Diff, Erc721Diff, Erc20Diff or NativeDiff.

type Client

type Client struct {
	Options []option.RequestOption
	Evm     *EvmService
	Site    *SiteService
	Token   *TokenService
}

Client creates a struct with services and top level methods that help with interacting with the blockaid API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r *Client)

NewClient generates a new client with the default option read from the environment (BLOCKAID_CLIENT_API_KEY). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned [url.Values] will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type Erc1155Diff

type Erc1155Diff struct {
	// id of the token
	TokenID int64 `json:"token_id,required"`
	// value before divided by decimal, that was transferred from this address
	Value string `json:"value,required"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// user friendly description of the asset transfer
	Summary string `json:"summary"`
	// usd equal of the asset that was transferred from this address
	UsdPrice string          `json:"usd_price"`
	JSON     erc1155DiffJSON `json:"-"`
}

func (*Erc1155Diff) UnmarshalJSON

func (r *Erc1155Diff) UnmarshalJSON(data []byte) (err error)

type Erc1155Exposure

type Erc1155Exposure struct {
	Exposure []Erc1155ExposureExposure `json:"exposure,required"`
	// boolean indicates whether an is_approved_for_all function was used (missing in
	// case of ERC20 / ERC1155)
	IsApprovedForAll bool `json:"is_approved_for_all,required"`
	// user friendly description of the approval
	Summary string              `json:"summary"`
	JSON    erc1155ExposureJSON `json:"-"`
}

func (*Erc1155Exposure) UnmarshalJSON

func (r *Erc1155Exposure) UnmarshalJSON(data []byte) (err error)

type Erc1155ExposureExposure

type Erc1155ExposureExposure struct {
	// usd equal of the asset that was transferred from this address
	UsdPrice string `json:"usd_price"`
	// user friendly description of the asset transfer
	Summary string `json:"summary"`
	// id of the token
	TokenID int64 `json:"token_id"`
	// value before divided by decimal, that was transferred from this address
	Value string `json:"value"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// value before divided by decimal, that was transferred from this address
	RawValue string                      `json:"raw_value"`
	JSON     erc1155ExposureExposureJSON `json:"-"`
	// contains filtered or unexported fields
}

func (Erc1155ExposureExposure) AsUnion

func (*Erc1155ExposureExposure) UnmarshalJSON

func (r *Erc1155ExposureExposure) UnmarshalJSON(data []byte) (err error)

type Erc1155ExposureExposureUnion

type Erc1155ExposureExposureUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by Erc1155Diff, Erc721Diff, Erc20Diff or NativeDiff.

type Erc1155TokenDetails

type Erc1155TokenDetails struct {
	// address of the token
	Address string `json:"address,required"`
	// asset type.
	Type Erc1155TokenDetailsType `json:"type,required"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// string represents the name of the asset
	Name string `json:"name"`
	// asset's symbol name
	Symbol string                  `json:"symbol"`
	JSON   erc1155TokenDetailsJSON `json:"-"`
}

func (*Erc1155TokenDetails) UnmarshalJSON

func (r *Erc1155TokenDetails) UnmarshalJSON(data []byte) (err error)

type Erc1155TokenDetailsType

type Erc1155TokenDetailsType string

asset type.

const (
	Erc1155TokenDetailsTypeErc1155 Erc1155TokenDetailsType = "ERC1155"
)

func (Erc1155TokenDetailsType) IsKnown

func (r Erc1155TokenDetailsType) IsKnown() bool

type Erc20Diff

type Erc20Diff struct {
	// value before divided by decimal, that was transferred from this address
	RawValue string `json:"raw_value,required"`
	// user friendly description of the asset transfer
	Summary string `json:"summary"`
	// usd equal of the asset that was transferred from this address
	UsdPrice string `json:"usd_price"`
	// value after divided by decimals, that was transferred from this address
	Value string        `json:"value"`
	JSON  erc20DiffJSON `json:"-"`
}

func (*Erc20Diff) UnmarshalJSON

func (r *Erc20Diff) UnmarshalJSON(data []byte) (err error)

type Erc20Exposure

type Erc20Exposure struct {
	// the amount that was asked in the approval request for this spender from the
	// current address and asset
	Approval int64                   `json:"approval,required"`
	Exposure []Erc20ExposureExposure `json:"exposure,required"`
	// the expiration time of the permit2 protocol
	Expiration time.Time `json:"expiration" format:"date-time"`
	// user friendly description of the approval
	Summary string            `json:"summary"`
	JSON    erc20ExposureJSON `json:"-"`
}

func (*Erc20Exposure) UnmarshalJSON

func (r *Erc20Exposure) UnmarshalJSON(data []byte) (err error)

type Erc20ExposureExposure

type Erc20ExposureExposure struct {
	// usd equal of the asset that was transferred from this address
	UsdPrice string `json:"usd_price"`
	// user friendly description of the asset transfer
	Summary string `json:"summary"`
	// id of the token
	TokenID int64 `json:"token_id"`
	// value before divided by decimal, that was transferred from this address
	Value string `json:"value"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// value before divided by decimal, that was transferred from this address
	RawValue string                    `json:"raw_value"`
	JSON     erc20ExposureExposureJSON `json:"-"`
	// contains filtered or unexported fields
}

func (Erc20ExposureExposure) AsUnion

func (*Erc20ExposureExposure) UnmarshalJSON

func (r *Erc20ExposureExposure) UnmarshalJSON(data []byte) (err error)

type Erc20ExposureExposureUnion

type Erc20ExposureExposureUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by Erc1155Diff, Erc721Diff, Erc20Diff or NativeDiff.

type Erc20TokenDetails

type Erc20TokenDetails struct {
	// address of the token
	Address string `json:"address,required"`
	// asset's decimals
	Decimals int64 `json:"decimals,required"`
	// asset type.
	Type Erc20TokenDetailsType `json:"type,required"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// string represents the name of the asset
	Name string `json:"name"`
	// asset's symbol name
	Symbol string                `json:"symbol"`
	JSON   erc20TokenDetailsJSON `json:"-"`
}

func (*Erc20TokenDetails) UnmarshalJSON

func (r *Erc20TokenDetails) UnmarshalJSON(data []byte) (err error)

type Erc20TokenDetailsType

type Erc20TokenDetailsType string

asset type.

const (
	Erc20TokenDetailsTypeErc20 Erc20TokenDetailsType = "ERC20"
)

func (Erc20TokenDetailsType) IsKnown

func (r Erc20TokenDetailsType) IsKnown() bool

type Erc721Diff

type Erc721Diff struct {
	// id of the token
	TokenID int64 `json:"token_id,required"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// user friendly description of the asset transfer
	Summary string `json:"summary"`
	// usd equal of the asset that was transferred from this address
	UsdPrice string         `json:"usd_price"`
	JSON     erc721DiffJSON `json:"-"`
}

func (*Erc721Diff) UnmarshalJSON

func (r *Erc721Diff) UnmarshalJSON(data []byte) (err error)

type Erc721Exposure

type Erc721Exposure struct {
	Exposure []Erc721ExposureExposure `json:"exposure,required"`
	// boolean indicates whether an is_approved_for_all function was used (missing in
	// case of ERC20 / ERC1155)
	IsApprovedForAll bool `json:"is_approved_for_all,required"`
	// user friendly description of the approval
	Summary string             `json:"summary"`
	JSON    erc721ExposureJSON `json:"-"`
}

func (*Erc721Exposure) UnmarshalJSON

func (r *Erc721Exposure) UnmarshalJSON(data []byte) (err error)

type Erc721ExposureExposure

type Erc721ExposureExposure struct {
	// usd equal of the asset that was transferred from this address
	UsdPrice string `json:"usd_price"`
	// user friendly description of the asset transfer
	Summary string `json:"summary"`
	// id of the token
	TokenID int64 `json:"token_id"`
	// value before divided by decimal, that was transferred from this address
	Value string `json:"value"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// value before divided by decimal, that was transferred from this address
	RawValue string                     `json:"raw_value"`
	JSON     erc721ExposureExposureJSON `json:"-"`
	// contains filtered or unexported fields
}

func (Erc721ExposureExposure) AsUnion

func (*Erc721ExposureExposure) UnmarshalJSON

func (r *Erc721ExposureExposure) UnmarshalJSON(data []byte) (err error)

type Erc721ExposureExposureUnion

type Erc721ExposureExposureUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by Erc1155Diff, Erc721Diff, Erc20Diff or NativeDiff.

type Erc721TokenDetails

type Erc721TokenDetails struct {
	// address of the token
	Address string `json:"address,required"`
	// asset type.
	Type Erc721TokenDetailsType `json:"type,required"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// string represents the name of the asset
	Name string `json:"name"`
	// asset's symbol name
	Symbol string                 `json:"symbol"`
	JSON   erc721TokenDetailsJSON `json:"-"`
}

func (*Erc721TokenDetails) UnmarshalJSON

func (r *Erc721TokenDetails) UnmarshalJSON(data []byte) (err error)

type Erc721TokenDetailsType

type Erc721TokenDetailsType string

asset type.

const (
	Erc721TokenDetailsTypeErc721 Erc721TokenDetailsType = "ERC721"
)

func (Erc721TokenDetailsType) IsKnown

func (r Erc721TokenDetailsType) IsKnown() bool

type Error

type Error = apierror.Error

type EvmJsonRpcScanParams

type EvmJsonRpcScanParams struct {
	// The chain name
	Chain param.Field[TransactionScanSupportedChain] `json:"chain,required"`
	// JSON-RPC request that was received by the wallet.
	Data param.Field[EvmJsonRpcScanParamsData] `json:"data,required"`
	// Object of additional information to validate against.
	Metadata param.Field[MetadataParam] `json:"metadata,required"`
	// The address of the account (wallet) received the request in hex string format
	AccountAddress param.Field[string] `json:"account_address"`
	// list of one or both of options for the desired output. "simulation" - include
	// simulation output in your response. "validation" - include security validation
	// of the transaction in your response. Default is ["validation"]
	Options param.Field[[]EvmJsonRpcScanParamsOption] `json:"options"`
}

func (EvmJsonRpcScanParams) MarshalJSON

func (r EvmJsonRpcScanParams) MarshalJSON() (data []byte, err error)

type EvmJsonRpcScanParamsData

type EvmJsonRpcScanParamsData struct {
	// The method of the JSON-RPC request
	Method param.Field[string] `json:"method,required"`
	// The parameters of the JSON-RPC request in JSON format
	Params param.Field[[]interface{}] `json:"params,required"`
}

JSON-RPC request that was received by the wallet.

func (EvmJsonRpcScanParamsData) MarshalJSON

func (r EvmJsonRpcScanParamsData) MarshalJSON() (data []byte, err error)

type EvmJsonRpcScanParamsOption

type EvmJsonRpcScanParamsOption string

An enumeration.

const (
	EvmJsonRpcScanParamsOptionValidation    EvmJsonRpcScanParamsOption = "validation"
	EvmJsonRpcScanParamsOptionSimulation    EvmJsonRpcScanParamsOption = "simulation"
	EvmJsonRpcScanParamsOptionGasEstimation EvmJsonRpcScanParamsOption = "gas_estimation"
	EvmJsonRpcScanParamsOptionEvents        EvmJsonRpcScanParamsOption = "events"
)

func (EvmJsonRpcScanParamsOption) IsKnown

func (r EvmJsonRpcScanParamsOption) IsKnown() bool

type EvmJsonRpcService

type EvmJsonRpcService struct {
	Options []option.RequestOption
}

EvmJsonRpcService contains methods and other services that help with interacting with the blockaid API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewEvmJsonRpcService method instead.

func NewEvmJsonRpcService

func NewEvmJsonRpcService(opts ...option.RequestOption) (r *EvmJsonRpcService)

NewEvmJsonRpcService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*EvmJsonRpcService) Scan

Gets a json-rpc request and returns a full simulation indicating what will happen in the transaction together with a recommended action and some textual reasons of why the transaction was flagged that way.

type EvmService

type EvmService struct {
	Options         []option.RequestOption
	JsonRpc         *EvmJsonRpcService
	Transaction     *EvmTransactionService
	TransactionBulk *EvmTransactionBulkService
	TransactionRaw  *EvmTransactionRawService
	UserOperation   *EvmUserOperationService
}

EvmService contains methods and other services that help with interacting with the blockaid API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewEvmService method instead.

func NewEvmService

func NewEvmService(opts ...option.RequestOption) (r *EvmService)

NewEvmService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type EvmTransactionBulkScanParams

type EvmTransactionBulkScanParams struct {
	// The chain name
	Chain param.Field[TransactionScanSupportedChain] `json:"chain,required"`
	// Transaction bulk parameters
	Data param.Field[[]EvmTransactionBulkScanParamsData] `json:"data,required"`
	// Object of additional information to validate against.
	Metadata param.Field[MetadataParam] `json:"metadata,required"`
	// List of one or both of options for the desired output. "simulation" - include
	// simulation output in your response. "validation" - include security validation
	// of the transaction in your response. Default is ["validation"]
	Options param.Field[[]EvmTransactionBulkScanParamsOption] `json:"options"`
}

func (EvmTransactionBulkScanParams) MarshalJSON

func (r EvmTransactionBulkScanParams) MarshalJSON() (data []byte, err error)

type EvmTransactionBulkScanParamsData

type EvmTransactionBulkScanParamsData struct {
	// The source address of the transaction in hex string format
	From param.Field[string] `json:"from,required"`
	// The encoded call data of the transaction in hex string format
	Data param.Field[string] `json:"data"`
	// The gas required for the transaction in hex string format.
	Gas param.Field[string] `json:"gas"`
	// The gas price for the transaction in hex string format.
	GasPrice param.Field[string] `json:"gas_price"`
	// The destination address of the transaction in hex string format
	To param.Field[string] `json:"to"`
	// The value of the transaction in Wei in hex string format
	Value param.Field[string] `json:"value"`
}

func (EvmTransactionBulkScanParamsData) MarshalJSON

func (r EvmTransactionBulkScanParamsData) MarshalJSON() (data []byte, err error)

type EvmTransactionBulkScanParamsOption

type EvmTransactionBulkScanParamsOption string

An enumeration.

const (
	EvmTransactionBulkScanParamsOptionValidation    EvmTransactionBulkScanParamsOption = "validation"
	EvmTransactionBulkScanParamsOptionSimulation    EvmTransactionBulkScanParamsOption = "simulation"
	EvmTransactionBulkScanParamsOptionGasEstimation EvmTransactionBulkScanParamsOption = "gas_estimation"
	EvmTransactionBulkScanParamsOptionEvents        EvmTransactionBulkScanParamsOption = "events"
)

func (EvmTransactionBulkScanParamsOption) IsKnown

type EvmTransactionBulkService

type EvmTransactionBulkService struct {
	Options []option.RequestOption
}

EvmTransactionBulkService contains methods and other services that help with interacting with the blockaid API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewEvmTransactionBulkService method instead.

func NewEvmTransactionBulkService

func NewEvmTransactionBulkService(opts ...option.RequestOption) (r *EvmTransactionBulkService)

NewEvmTransactionBulkService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*EvmTransactionBulkService) Scan

Gets a bulk of transactions and returns a simulation showcasing the outcome after executing the transactions synchronously, along with a suggested course of action and textual explanations highlighting the reasons for flagging the bulk in that manner.

type EvmTransactionRawScanParams

type EvmTransactionRawScanParams struct {
	// The address to relate the transaction to. Account address determines in which
	// perspective the transaction is simulated and validated.
	AccountAddress param.Field[string] `json:"account_address,required"`
	// The chain name
	Chain param.Field[TransactionScanSupportedChain] `json:"chain,required"`
	// Hex string of the raw transaction data
	Data param.Field[string] `json:"data,required"`
	// Object of additional information to validate against.
	Metadata param.Field[MetadataParam] `json:"metadata,required"`
	// list of one or both of options for the desired output. "simulation" - include
	// simulation output in your response. "validation" - include security validation
	// of the transaction in your response. Default is ["validation"]
	Options param.Field[[]EvmTransactionRawScanParamsOption] `json:"options"`
}

func (EvmTransactionRawScanParams) MarshalJSON

func (r EvmTransactionRawScanParams) MarshalJSON() (data []byte, err error)

type EvmTransactionRawScanParamsOption

type EvmTransactionRawScanParamsOption string

An enumeration.

const (
	EvmTransactionRawScanParamsOptionValidation    EvmTransactionRawScanParamsOption = "validation"
	EvmTransactionRawScanParamsOptionSimulation    EvmTransactionRawScanParamsOption = "simulation"
	EvmTransactionRawScanParamsOptionGasEstimation EvmTransactionRawScanParamsOption = "gas_estimation"
	EvmTransactionRawScanParamsOptionEvents        EvmTransactionRawScanParamsOption = "events"
)

func (EvmTransactionRawScanParamsOption) IsKnown

type EvmTransactionRawService

type EvmTransactionRawService struct {
	Options []option.RequestOption
}

EvmTransactionRawService contains methods and other services that help with interacting with the blockaid API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewEvmTransactionRawService method instead.

func NewEvmTransactionRawService

func NewEvmTransactionRawService(opts ...option.RequestOption) (r *EvmTransactionRawService)

NewEvmTransactionRawService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*EvmTransactionRawService) Scan

Gets a raw transaction and returns a full simulation indicating what will happen in the transaction together with a recommended action and some textual reasons of why the transaction was flagged that way.

type EvmTransactionScanParams

type EvmTransactionScanParams struct {
	// The address to relate the transaction to. Account address determines in which
	// perspective the transaction is simulated and validated.
	AccountAddress param.Field[string] `json:"account_address,required"`
	// The chain name
	Chain param.Field[TransactionScanSupportedChain] `json:"chain,required"`
	// Transaction parameters
	Data param.Field[EvmTransactionScanParamsData] `json:"data,required"`
	// Object of additional information to validate against.
	Metadata param.Field[MetadataParam] `json:"metadata,required"`
	// list of one or both of options for the desired output. "simulation" - include
	// simulation output in your response. "validation" - include security validation
	// of the transaction in your response. Default is ["validation"]
	Options param.Field[[]EvmTransactionScanParamsOption] `json:"options"`
}

func (EvmTransactionScanParams) MarshalJSON

func (r EvmTransactionScanParams) MarshalJSON() (data []byte, err error)

type EvmTransactionScanParamsData

type EvmTransactionScanParamsData struct {
	// The source address of the transaction in hex string format
	From param.Field[string] `json:"from,required"`
	// The encoded call data of the transaction in hex string format
	Data param.Field[string] `json:"data"`
	// The gas required for the transaction in hex string format.
	Gas param.Field[string] `json:"gas"`
	// The gas price for the transaction in hex string format.
	GasPrice param.Field[string] `json:"gas_price"`
	// The destination address of the transaction in hex string format
	To param.Field[string] `json:"to"`
	// The value of the transaction in Wei in hex string format
	Value param.Field[string] `json:"value"`
}

Transaction parameters

func (EvmTransactionScanParamsData) MarshalJSON

func (r EvmTransactionScanParamsData) MarshalJSON() (data []byte, err error)

type EvmTransactionScanParamsOption

type EvmTransactionScanParamsOption string

An enumeration.

const (
	EvmTransactionScanParamsOptionValidation    EvmTransactionScanParamsOption = "validation"
	EvmTransactionScanParamsOptionSimulation    EvmTransactionScanParamsOption = "simulation"
	EvmTransactionScanParamsOptionGasEstimation EvmTransactionScanParamsOption = "gas_estimation"
	EvmTransactionScanParamsOptionEvents        EvmTransactionScanParamsOption = "events"
)

func (EvmTransactionScanParamsOption) IsKnown

type EvmTransactionService

type EvmTransactionService struct {
	Options []option.RequestOption
}

EvmTransactionService contains methods and other services that help with interacting with the blockaid API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewEvmTransactionService method instead.

func NewEvmTransactionService

func NewEvmTransactionService(opts ...option.RequestOption) (r *EvmTransactionService)

NewEvmTransactionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*EvmTransactionService) Scan

Gets a transaction and returns a full simulation indicating what will happen in the transaction together with a recommended action and some textual reasons of why the transaction was flagged that way.

type EvmUserOperationScanParams added in v0.7.0

type EvmUserOperationScanParams struct {
	// The chain name
	Chain param.Field[TransactionScanSupportedChain] `json:"chain,required"`
	// The user operation request that was received by the wallet
	Data param.Field[EvmUserOperationScanParamsData] `json:"data,required"`
	// Object of additional information to validate against.
	Metadata param.Field[MetadataParam] `json:"metadata,required"`
	// The address of the account (wallet) sending the request in hex string format
	AccountAddress param.Field[string] `json:"account_address"`
	// list of one or both of options for the desired output. "simulation" - include
	// simulation output in your response. "validation" - include security validation
	// of the transaction in your response. Default is ["validation"]
	Options param.Field[[]EvmUserOperationScanParamsOption] `json:"options"`
}

func (EvmUserOperationScanParams) MarshalJSON added in v0.7.0

func (r EvmUserOperationScanParams) MarshalJSON() (data []byte, err error)

type EvmUserOperationScanParamsData added in v0.7.0

type EvmUserOperationScanParamsData struct {
	// The operation parameters of the user operation request
	Operation param.Field[EvmUserOperationScanParamsDataOperation] `json:"operation,required"`
	// The address of the entrypoint receiving the request in hex string format
	Entrypoint param.Field[string] `json:"entrypoint"`
}

The user operation request that was received by the wallet

func (EvmUserOperationScanParamsData) MarshalJSON added in v0.7.0

func (r EvmUserOperationScanParamsData) MarshalJSON() (data []byte, err error)

type EvmUserOperationScanParamsDataOperation added in v0.7.0

type EvmUserOperationScanParamsDataOperation struct {
	// The call data value in hex string format.
	CallData param.Field[string] `json:"call_data"`
	// The call gas limit value in hex string format.
	CallGasLimit param.Field[string] `json:"call_gas_limit"`
	// The init code value in hex string format.
	InitCode param.Field[string] `json:"init_code"`
	// The max fee per gas value in hex string format.
	MaxFeePerGas param.Field[string] `json:"max_fee_per_gas"`
	// The max priority fee per gas value in hex string format.
	MaxPriorityFeePerGas param.Field[string] `json:"max_priority_fee_per_gas"`
	// The nonce value in hex string format.
	Nonce param.Field[string] `json:"nonce"`
	// The paymaster and data value in hex string format.
	PaymasterAndData param.Field[string] `json:"paymaster_and_data"`
	// The pre verification gas value in hex string format.
	PreVerificationGas param.Field[string] `json:"pre_verification_gas"`
	// The sender address of the operation in hex string format
	Sender param.Field[string] `json:"sender"`
	// The signature value in hex string format.
	Signature param.Field[string] `json:"signature"`
	// The verification gas limit value in hex string format.
	VerificationGasLimit param.Field[string] `json:"verification_gas_limit"`
}

The operation parameters of the user operation request

func (EvmUserOperationScanParamsDataOperation) MarshalJSON added in v0.7.0

func (r EvmUserOperationScanParamsDataOperation) MarshalJSON() (data []byte, err error)

type EvmUserOperationScanParamsOption added in v0.7.0

type EvmUserOperationScanParamsOption string

An enumeration.

const (
	EvmUserOperationScanParamsOptionValidation    EvmUserOperationScanParamsOption = "validation"
	EvmUserOperationScanParamsOptionSimulation    EvmUserOperationScanParamsOption = "simulation"
	EvmUserOperationScanParamsOptionGasEstimation EvmUserOperationScanParamsOption = "gas_estimation"
	EvmUserOperationScanParamsOptionEvents        EvmUserOperationScanParamsOption = "events"
)

func (EvmUserOperationScanParamsOption) IsKnown added in v0.7.0

type EvmUserOperationService

type EvmUserOperationService struct {
	Options []option.RequestOption
}

EvmUserOperationService contains methods and other services that help with interacting with the blockaid API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewEvmUserOperationService method instead.

func NewEvmUserOperationService

func NewEvmUserOperationService(opts ...option.RequestOption) (r *EvmUserOperationService)

NewEvmUserOperationService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*EvmUserOperationService) Scan added in v0.7.0

Gets a user operation request and returns a full simulation indicating what will happen in the transaction together with a recommended action and some textual reasons of why the transaction was flagged that way.

type MetadataParam

type MetadataParam struct {
	// cross reference transaction against the domain.
	Domain param.Field[string] `json:"domain,required"`
}

func (MetadataParam) MarshalJSON

func (r MetadataParam) MarshalJSON() (data []byte, err error)

type NativeAssetDetails added in v0.7.3

type NativeAssetDetails struct {
	ChainID   int64  `json:"chain_id,required"`
	ChainName string `json:"chain_name,required"`
	Decimals  int64  `json:"decimals,required"`
	LogoURL   string `json:"logo_url,required"`
	// asset type.
	Type NativeAssetDetailsType `json:"type,required"`
	// string represents the name of the asset
	Name string `json:"name"`
	// asset's symbol name
	Symbol string                 `json:"symbol"`
	JSON   nativeAssetDetailsJSON `json:"-"`
}

func (*NativeAssetDetails) UnmarshalJSON added in v0.7.3

func (r *NativeAssetDetails) UnmarshalJSON(data []byte) (err error)

type NativeAssetDetailsType added in v0.7.3

type NativeAssetDetailsType string

asset type.

const (
	NativeAssetDetailsTypeNative NativeAssetDetailsType = "NATIVE"
)

func (NativeAssetDetailsType) IsKnown added in v0.7.3

func (r NativeAssetDetailsType) IsKnown() bool

type NativeDiff

type NativeDiff struct {
	// value before divided by decimal, that was transferred from this address
	RawValue string `json:"raw_value,required"`
	// user friendly description of the asset transfer
	Summary string `json:"summary"`
	// usd equal of the asset that was transferred from this address
	UsdPrice string `json:"usd_price"`
	// value after divided by decimals, that was transferred from this address
	Value string         `json:"value"`
	JSON  nativeDiffJSON `json:"-"`
}

func (*NativeDiff) UnmarshalJSON

func (r *NativeDiff) UnmarshalJSON(data []byte) (err error)

type NonercTokenDetails

type NonercTokenDetails struct {
	// address of the token
	Address string `json:"address,required"`
	// asset type.
	Type NonercTokenDetailsType `json:"type,required"`
	// url of the token logo
	LogoURL string `json:"logo_url"`
	// string represents the name of the asset
	Name string `json:"name"`
	// asset's symbol name
	Symbol string                 `json:"symbol"`
	JSON   nonercTokenDetailsJSON `json:"-"`
}

func (*NonercTokenDetails) UnmarshalJSON

func (r *NonercTokenDetails) UnmarshalJSON(data []byte) (err error)

type NonercTokenDetailsType

type NonercTokenDetailsType string

asset type.

const (
	NonercTokenDetailsTypeNonerc NonercTokenDetailsType = "NONERC"
)

func (NonercTokenDetailsType) IsKnown

func (r NonercTokenDetailsType) IsKnown() bool

type SiteScanHitResponse

type SiteScanHitResponse struct {
	AttackTypes       map[string]SiteScanHitResponseAttackType `json:"attack_types,required"`
	ContractRead      SiteScanHitResponseContractRead          `json:"contract_read,required"`
	ContractWrite     SiteScanHitResponseContractWrite         `json:"contract_write,required"`
	IsMalicious       bool                                     `json:"is_malicious,required"`
	IsReachable       bool                                     `json:"is_reachable,required"`
	IsWeb3Site        bool                                     `json:"is_web3_site,required"`
	JsonRpcOperations []string                                 `json:"json_rpc_operations,required"`
	MaliciousScore    float64                                  `json:"malicious_score,required"`
	NetworkOperations []string                                 `json:"network_operations,required"`
	ScanEndTime       time.Time                                `json:"scan_end_time,required" format:"date-time"`
	ScanStartTime     time.Time                                `json:"scan_start_time,required" format:"date-time"`
	Status            SiteScanHitResponseStatus                `json:"status,required"`
	URL               string                                   `json:"url,required"`
	JSON              siteScanHitResponseJSON                  `json:"-"`
}

func (*SiteScanHitResponse) UnmarshalJSON

func (r *SiteScanHitResponse) UnmarshalJSON(data []byte) (err error)

type SiteScanHitResponseAttackType

type SiteScanHitResponseAttackType struct {
	Score     float64                           `json:"score,required"`
	Threshold float64                           `json:"threshold,required"`
	JSON      siteScanHitResponseAttackTypeJSON `json:"-"`
}

func (*SiteScanHitResponseAttackType) UnmarshalJSON

func (r *SiteScanHitResponseAttackType) UnmarshalJSON(data []byte) (err error)

type SiteScanHitResponseContractRead

type SiteScanHitResponseContractRead struct {
	ContractAddresses []string                            `json:"contract_addresses,required"`
	Functions         map[string][]string                 `json:"functions,required"`
	JSON              siteScanHitResponseContractReadJSON `json:"-"`
}

func (*SiteScanHitResponseContractRead) UnmarshalJSON

func (r *SiteScanHitResponseContractRead) UnmarshalJSON(data []byte) (err error)

type SiteScanHitResponseContractWrite

type SiteScanHitResponseContractWrite struct {
	ContractAddresses []string                             `json:"contract_addresses,required"`
	Functions         map[string][]string                  `json:"functions,required"`
	JSON              siteScanHitResponseContractWriteJSON `json:"-"`
}

func (*SiteScanHitResponseContractWrite) UnmarshalJSON

func (r *SiteScanHitResponseContractWrite) UnmarshalJSON(data []byte) (err error)

type SiteScanHitResponseStatus

type SiteScanHitResponseStatus string
const (
	SiteScanHitResponseStatusHit SiteScanHitResponseStatus = "hit"
)

func (SiteScanHitResponseStatus) IsKnown

func (r SiteScanHitResponseStatus) IsKnown() bool

type SiteScanMissResponse

type SiteScanMissResponse struct {
	Status SiteScanMissResponseStatus `json:"status,required"`
	JSON   siteScanMissResponseJSON   `json:"-"`
}

func (*SiteScanMissResponse) UnmarshalJSON

func (r *SiteScanMissResponse) UnmarshalJSON(data []byte) (err error)

type SiteScanMissResponseStatus

type SiteScanMissResponseStatus string
const (
	SiteScanMissResponseStatusMiss SiteScanMissResponseStatus = "miss"
)

func (SiteScanMissResponseStatus) IsKnown

func (r SiteScanMissResponseStatus) IsKnown() bool

type SiteScanParams

type SiteScanParams struct {
	URL      param.Field[string]                      `json:"url,required"`
	Metadata param.Field[SiteScanParamsMetadataUnion] `json:"metadata"`
}

func (SiteScanParams) MarshalJSON

func (r SiteScanParams) MarshalJSON() (data []byte, err error)

type SiteScanParamsMetadata

type SiteScanParamsMetadata struct {
	Type           param.Field[SiteScanParamsMetadataType] `json:"type,required"`
	AccountAddress param.Field[string]                     `json:"account_address"`
}

func (SiteScanParamsMetadata) MarshalJSON

func (r SiteScanParamsMetadata) MarshalJSON() (data []byte, err error)

type SiteScanParamsMetadataCatalogRequestMetadata

type SiteScanParamsMetadataCatalogRequestMetadata struct {
	Type param.Field[SiteScanParamsMetadataCatalogRequestMetadataType] `json:"type,required"`
}

func (SiteScanParamsMetadataCatalogRequestMetadata) MarshalJSON

func (r SiteScanParamsMetadataCatalogRequestMetadata) MarshalJSON() (data []byte, err error)

type SiteScanParamsMetadataCatalogRequestMetadataType

type SiteScanParamsMetadataCatalogRequestMetadataType string
const (
	SiteScanParamsMetadataCatalogRequestMetadataTypeCatalog SiteScanParamsMetadataCatalogRequestMetadataType = "catalog"
)

func (SiteScanParamsMetadataCatalogRequestMetadataType) IsKnown

type SiteScanParamsMetadataType

type SiteScanParamsMetadataType string
const (
	SiteScanParamsMetadataTypeCatalog SiteScanParamsMetadataType = "catalog"
	SiteScanParamsMetadataTypeWallet  SiteScanParamsMetadataType = "wallet"
)

func (SiteScanParamsMetadataType) IsKnown

func (r SiteScanParamsMetadataType) IsKnown() bool

type SiteScanParamsMetadataUnion

type SiteScanParamsMetadataUnion interface {
	// contains filtered or unexported methods
}

Satisfied by SiteScanParamsMetadataCatalogRequestMetadata, SiteScanParamsMetadataWalletRequestMetadata, SiteScanParamsMetadata.

type SiteScanParamsMetadataWalletRequestMetadata

type SiteScanParamsMetadataWalletRequestMetadata struct {
	AccountAddress param.Field[string]                                          `json:"account_address,required"`
	Type           param.Field[SiteScanParamsMetadataWalletRequestMetadataType] `json:"type,required"`
}

func (SiteScanParamsMetadataWalletRequestMetadata) MarshalJSON

func (r SiteScanParamsMetadataWalletRequestMetadata) MarshalJSON() (data []byte, err error)

type SiteScanParamsMetadataWalletRequestMetadataType

type SiteScanParamsMetadataWalletRequestMetadataType string
const (
	SiteScanParamsMetadataWalletRequestMetadataTypeWallet SiteScanParamsMetadataWalletRequestMetadataType = "wallet"
)

func (SiteScanParamsMetadataWalletRequestMetadataType) IsKnown

type SiteScanResponse

type SiteScanResponse struct {
	Status            SiteScanResponseStatus `json:"status,required"`
	URL               string                 `json:"url"`
	ScanStartTime     time.Time              `json:"scan_start_time" format:"date-time"`
	ScanEndTime       time.Time              `json:"scan_end_time" format:"date-time"`
	MaliciousScore    float64                `json:"malicious_score"`
	IsReachable       bool                   `json:"is_reachable"`
	IsWeb3Site        bool                   `json:"is_web3_site"`
	IsMalicious       bool                   `json:"is_malicious"`
	AttackTypes       interface{}            `json:"attack_types,required"`
	NetworkOperations interface{}            `json:"network_operations,required"`
	JsonRpcOperations interface{}            `json:"json_rpc_operations,required"`
	ContractWrite     interface{}            `json:"contract_write,required"`
	ContractRead      interface{}            `json:"contract_read,required"`
	JSON              siteScanResponseJSON   `json:"-"`
	// contains filtered or unexported fields
}

func (SiteScanResponse) AsUnion

func (*SiteScanResponse) UnmarshalJSON

func (r *SiteScanResponse) UnmarshalJSON(data []byte) (err error)

type SiteScanResponseStatus

type SiteScanResponseStatus string
const (
	SiteScanResponseStatusHit  SiteScanResponseStatus = "hit"
	SiteScanResponseStatusMiss SiteScanResponseStatus = "miss"
)

func (SiteScanResponseStatus) IsKnown

func (r SiteScanResponseStatus) IsKnown() bool

type SiteScanResponseUnion

type SiteScanResponseUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by SiteScanHitResponse or SiteScanMissResponse.

type SiteService

type SiteService struct {
	Options []option.RequestOption
}

SiteService contains methods and other services that help with interacting with the blockaid API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewSiteService method instead.

func NewSiteService

func NewSiteService(opts ...option.RequestOption) (r *SiteService)

NewSiteService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*SiteService) Scan

func (r *SiteService) Scan(ctx context.Context, body SiteScanParams, opts ...option.RequestOption) (res *SiteScanResponse, err error)

Scan Site

type TokenScanParams added in v0.7.6

type TokenScanParams struct {
	// Token address to validate (EVM / Solana)
	Address param.Field[TokenScanParamsAddressUnion] `json:"address,required"`
	// The chain name
	Chain param.Field[TokenScanSupportedChain] `json:"chain,required"`
	// Object of additional information to validate against.
	Metadata param.Field[TokenScanParamsMetadata] `json:"metadata"`
}

func (TokenScanParams) MarshalJSON added in v0.7.6

func (r TokenScanParams) MarshalJSON() (data []byte, err error)

type TokenScanParamsAddressUnion added in v0.7.6

type TokenScanParamsAddressUnion interface {
	ImplementsTokenScanParamsAddressUnion()
}

Token address to validate (EVM / Solana)

Satisfied by shared.UnionString, shared.UnionString.

type TokenScanParamsMetadata added in v0.7.6

type TokenScanParamsMetadata struct {
	// cross reference transaction against the domain.
	Domain param.Field[string] `json:"domain"`
}

Object of additional information to validate against.

func (TokenScanParamsMetadata) MarshalJSON added in v0.7.6

func (r TokenScanParamsMetadata) MarshalJSON() (data []byte, err error)

type TokenScanResponse added in v0.7.6

type TokenScanResponse struct {
	// Dictionary of detected attacks found during the scan
	AttackTypes map[string]TokenScanResponseAttackType `json:"attack_types,required"`
	// Score between 0 to 1 (double)
	MaliciousScore string `json:"malicious_score,required"`
	// An enumeration.
	ResultType TokenScanResponseResultType `json:"result_type,required"`
	JSON       tokenScanResponseJSON       `json:"-"`
}

func (*TokenScanResponse) UnmarshalJSON added in v0.7.6

func (r *TokenScanResponse) UnmarshalJSON(data []byte) (err error)

type TokenScanResponseAttackType added in v0.7.6

type TokenScanResponseAttackType struct {
	// Score between 0 to 1 (double) that indicates the assurance this attack happened
	Score string `json:"score,required"`
	// Object contains an extra information related to the attack
	Features interface{} `json:"features"`
	// If score is higher or equal to this field, the token is using this attack type
	Threshold string                          `json:"threshold"`
	JSON      tokenScanResponseAttackTypeJSON `json:"-"`
}

func (*TokenScanResponseAttackType) UnmarshalJSON added in v0.7.6

func (r *TokenScanResponseAttackType) UnmarshalJSON(data []byte) (err error)

type TokenScanResponseResultType added in v0.7.6

type TokenScanResponseResultType string

An enumeration.

const (
	TokenScanResponseResultTypeBenign    TokenScanResponseResultType = "Benign"
	TokenScanResponseResultTypeWarning   TokenScanResponseResultType = "Warning"
	TokenScanResponseResultTypeMalicious TokenScanResponseResultType = "Malicious"
	TokenScanResponseResultTypeSpam      TokenScanResponseResultType = "Spam"
)

func (TokenScanResponseResultType) IsKnown added in v0.7.6

func (r TokenScanResponseResultType) IsKnown() bool

type TokenScanSupportedChain added in v0.7.6

type TokenScanSupportedChain string

The chain name

const (
	TokenScanSupportedChainArbitrum  TokenScanSupportedChain = "arbitrum"
	TokenScanSupportedChainAvalanche TokenScanSupportedChain = "avalanche"
	TokenScanSupportedChainBase      TokenScanSupportedChain = "base"
	TokenScanSupportedChainBsc       TokenScanSupportedChain = "bsc"
	TokenScanSupportedChainEthereum  TokenScanSupportedChain = "ethereum"
	TokenScanSupportedChainOptimism  TokenScanSupportedChain = "optimism"
	TokenScanSupportedChainPolygon   TokenScanSupportedChain = "polygon"
	TokenScanSupportedChainZora      TokenScanSupportedChain = "zora"
	TokenScanSupportedChainSolana    TokenScanSupportedChain = "solana"
	TokenScanSupportedChainUnknown   TokenScanSupportedChain = "unknown"
)

func (TokenScanSupportedChain) IsKnown added in v0.7.6

func (r TokenScanSupportedChain) IsKnown() bool

type TokenService added in v0.7.6

type TokenService struct {
	Options []option.RequestOption
}

TokenService contains methods and other services that help with interacting with the blockaid API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewTokenService method instead.

func NewTokenService added in v0.7.6

func NewTokenService(opts ...option.RequestOption) (r *TokenService)

NewTokenService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*TokenService) Scan added in v0.7.6

func (r *TokenService) Scan(ctx context.Context, body TokenScanParams, opts ...option.RequestOption) (res *TokenScanResponse, err error)

Gets a token address and scan the token to identify any indication of malicious behaviour

type TransactionScanFeature

type TransactionScanFeature struct {
	// Textual description
	Description string `json:"description,required"`
	// Feature name
	FeatureID string `json:"feature_id,required"`
	// An enumeration.
	Type TransactionScanFeatureType `json:"type,required"`
	// Address the feature refers to
	Address string                     `json:"address"`
	JSON    transactionScanFeatureJSON `json:"-"`
}

func (*TransactionScanFeature) UnmarshalJSON

func (r *TransactionScanFeature) UnmarshalJSON(data []byte) (err error)

type TransactionScanFeatureType

type TransactionScanFeatureType string

An enumeration.

const (
	TransactionScanFeatureTypeMalicious TransactionScanFeatureType = "Malicious"
	TransactionScanFeatureTypeWarning   TransactionScanFeatureType = "Warning"
	TransactionScanFeatureTypeBenign    TransactionScanFeatureType = "Benign"
	TransactionScanFeatureTypeInfo      TransactionScanFeatureType = "Info"
)

func (TransactionScanFeatureType) IsKnown

func (r TransactionScanFeatureType) IsKnown() bool

type TransactionScanResponse

type TransactionScanResponse struct {
	Block         string                               `json:"block,required"`
	Chain         string                               `json:"chain,required"`
	Events        []TransactionScanResponseEvent       `json:"events"`
	Features      interface{}                          `json:"features"`
	GasEstimation TransactionScanResponseGasEstimation `json:"gas_estimation"`
	Simulation    TransactionScanResponseSimulation    `json:"simulation"`
	Validation    TransactionScanResponseValidation    `json:"validation"`
	JSON          transactionScanResponseJSON          `json:"-"`
}

func (*TransactionScanResponse) UnmarshalJSON

func (r *TransactionScanResponse) UnmarshalJSON(data []byte) (err error)

type TransactionScanResponseEvent added in v0.7.5

type TransactionScanResponseEvent struct {
	Data           string                               `json:"data,required"`
	EmitterAddress string                               `json:"emitter_address,required"`
	Topics         []string                             `json:"topics,required"`
	EmitterName    string                               `json:"emitter_name"`
	Name           string                               `json:"name"`
	Params         []TransactionScanResponseEventsParam `json:"params"`
	JSON           transactionScanResponseEventJSON     `json:"-"`
}

func (*TransactionScanResponseEvent) UnmarshalJSON added in v0.7.5

func (r *TransactionScanResponseEvent) UnmarshalJSON(data []byte) (err error)

type TransactionScanResponseEventsParam added in v0.7.5

type TransactionScanResponseEventsParam struct {
	Type         string                                        `json:"type,required"`
	Value        TransactionScanResponseEventsParamsValueUnion `json:"value,required"`
	InternalType string                                        `json:"internalType"`
	Name         string                                        `json:"name"`
	JSON         transactionScanResponseEventsParamJSON        `json:"-"`
}

func (*TransactionScanResponseEventsParam) UnmarshalJSON added in v0.7.5

func (r *TransactionScanResponseEventsParam) UnmarshalJSON(data []byte) (err error)

type TransactionScanResponseEventsParamsValueArray added in v0.7.5

type TransactionScanResponseEventsParamsValueArray []interface{}

func (TransactionScanResponseEventsParamsValueArray) ImplementsTransactionScanResponseEventsParamsValueUnion added in v0.7.5

func (r TransactionScanResponseEventsParamsValueArray) ImplementsTransactionScanResponseEventsParamsValueUnion()

type TransactionScanResponseEventsParamsValueUnion added in v0.7.5

type TransactionScanResponseEventsParamsValueUnion interface {
	ImplementsTransactionScanResponseEventsParamsValueUnion()
}

Union satisfied by shared.UnionString, [TransactionScanResponseEventsParamsValueUnknown] or TransactionScanResponseEventsParamsValueArray.

type TransactionScanResponseGasEstimation added in v0.7.5

type TransactionScanResponseGasEstimation struct {
	Status   TransactionScanResponseGasEstimationStatus `json:"status,required"`
	Used     int64                                      `json:"used"`
	Estimate int64                                      `json:"estimate"`
	Error    string                                     `json:"error"`
	JSON     transactionScanResponseGasEstimationJSON   `json:"-"`
	// contains filtered or unexported fields
}

func (TransactionScanResponseGasEstimation) AsUnion added in v0.7.5

func (*TransactionScanResponseGasEstimation) UnmarshalJSON added in v0.7.5

func (r *TransactionScanResponseGasEstimation) UnmarshalJSON(data []byte) (err error)

type TransactionScanResponseGasEstimationStatus added in v0.8.0

type TransactionScanResponseGasEstimationStatus string
const (
	TransactionScanResponseGasEstimationStatusSuccess TransactionScanResponseGasEstimationStatus = "Success"
	TransactionScanResponseGasEstimationStatusError   TransactionScanResponseGasEstimationStatus = "Error"
)

func (TransactionScanResponseGasEstimationStatus) IsKnown added in v0.8.0

type TransactionScanResponseGasEstimationTransactionScanGasEstimation added in v0.7.5

type TransactionScanResponseGasEstimationTransactionScanGasEstimation struct {
	Estimate int64                                                                  `json:"estimate,required"`
	Status   TransactionScanResponseGasEstimationTransactionScanGasEstimationStatus `json:"status,required"`
	Used     int64                                                                  `json:"used,required"`
	JSON     transactionScanResponseGasEstimationTransactionScanGasEstimationJSON   `json:"-"`
}

func (*TransactionScanResponseGasEstimationTransactionScanGasEstimation) UnmarshalJSON added in v0.7.5

type TransactionScanResponseGasEstimationTransactionScanGasEstimationError added in v0.7.5

type TransactionScanResponseGasEstimationTransactionScanGasEstimationError struct {
	Error  string                                                                      `json:"error,required"`
	Status TransactionScanResponseGasEstimationTransactionScanGasEstimationErrorStatus `json:"status,required"`
	JSON   transactionScanResponseGasEstimationTransactionScanGasEstimationErrorJSON   `json:"-"`
}

func (*TransactionScanResponseGasEstimationTransactionScanGasEstimationError) UnmarshalJSON added in v0.7.5

type TransactionScanResponseGasEstimationTransactionScanGasEstimationErrorStatus added in v0.8.0

type TransactionScanResponseGasEstimationTransactionScanGasEstimationErrorStatus string
const (
	TransactionScanResponseGasEstimationTransactionScanGasEstimationErrorStatusError TransactionScanResponseGasEstimationTransactionScanGasEstimationErrorStatus = "Error"
)

func (TransactionScanResponseGasEstimationTransactionScanGasEstimationErrorStatus) IsKnown added in v0.8.0

type TransactionScanResponseGasEstimationTransactionScanGasEstimationStatus added in v0.8.0

type TransactionScanResponseGasEstimationTransactionScanGasEstimationStatus string
const (
	TransactionScanResponseGasEstimationTransactionScanGasEstimationStatusSuccess TransactionScanResponseGasEstimationTransactionScanGasEstimationStatus = "Success"
)

func (TransactionScanResponseGasEstimationTransactionScanGasEstimationStatus) IsKnown added in v0.8.0

type TransactionScanResponseGasEstimationUnion added in v0.7.5

type TransactionScanResponseGasEstimationUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by TransactionScanResponseGasEstimationTransactionScanGasEstimation or TransactionScanResponseGasEstimationTransactionScanGasEstimationError.

type TransactionScanResponseSimulation

type TransactionScanResponseSimulation struct {
	// A string indicating if the simulation was successful or not.
	Status           TransactionScanResponseSimulationStatus `json:"status,required"`
	AssetsDiffs      interface{}                             `json:"assets_diffs,required"`
	TotalUsdDiff     interface{}                             `json:"total_usd_diff,required"`
	Exposures        interface{}                             `json:"exposures,required"`
	TotalUsdExposure interface{}                             `json:"total_usd_exposure,required"`
	AddressDetails   interface{}                             `json:"address_details,required"`
	AccountSummary   interface{}                             `json:"account_summary,required"`
	// An error message if the simulation failed.
	Error string                                `json:"error"`
	JSON  transactionScanResponseSimulationJSON `json:"-"`
	// contains filtered or unexported fields
}

func (TransactionScanResponseSimulation) AsUnion

func (*TransactionScanResponseSimulation) UnmarshalJSON

func (r *TransactionScanResponseSimulation) UnmarshalJSON(data []byte) (err error)

type TransactionScanResponseSimulationStatus added in v0.8.0

type TransactionScanResponseSimulationStatus string

A string indicating if the simulation was successful or not.

const (
	TransactionScanResponseSimulationStatusSuccess TransactionScanResponseSimulationStatus = "Success"
	TransactionScanResponseSimulationStatusError   TransactionScanResponseSimulationStatus = "Error"
)

func (TransactionScanResponseSimulationStatus) IsKnown added in v0.8.0

type TransactionScanResponseSimulationUnion

type TransactionScanResponseSimulationUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by TransactionSimulation or TransactionSimulationError.

type TransactionScanResponseValidation

type TransactionScanResponseValidation struct {
	// A string indicating if the simulation was successful or not.
	Status TransactionScanResponseValidationStatus `json:"status,required"`
	// An enumeration.
	ResultType TransactionScanResponseValidationResultType `json:"result_type,required"`
	// A textual description that can be presented to the user about what this
	// transaction is doing.
	Description string `json:"description"`
	// A textual description about the reasons the transaction was flagged with
	// result_type.
	Reason string `json:"reason"`
	// A textual classification that can be presented to the user explaining the
	// reason.
	Classification string      `json:"classification"`
	Features       interface{} `json:"features"`
	// An error message if the validation failed.
	Error string                                `json:"error"`
	JSON  transactionScanResponseValidationJSON `json:"-"`
	// contains filtered or unexported fields
}

func (TransactionScanResponseValidation) AsUnion

func (*TransactionScanResponseValidation) UnmarshalJSON

func (r *TransactionScanResponseValidation) UnmarshalJSON(data []byte) (err error)

type TransactionScanResponseValidationResultType

type TransactionScanResponseValidationResultType string

An enumeration.

const (
	TransactionScanResponseValidationResultTypeBenign    TransactionScanResponseValidationResultType = "Benign"
	TransactionScanResponseValidationResultTypeWarning   TransactionScanResponseValidationResultType = "Warning"
	TransactionScanResponseValidationResultTypeMalicious TransactionScanResponseValidationResultType = "Malicious"
	TransactionScanResponseValidationResultTypeError     TransactionScanResponseValidationResultType = "Error"
)

func (TransactionScanResponseValidationResultType) IsKnown

type TransactionScanResponseValidationStatus added in v0.9.1

type TransactionScanResponseValidationStatus string

A string indicating if the simulation was successful or not.

const (
	TransactionScanResponseValidationStatusSuccess TransactionScanResponseValidationStatus = "Success"
)

func (TransactionScanResponseValidationStatus) IsKnown added in v0.9.1

type TransactionScanResponseValidationUnion

type TransactionScanResponseValidationUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by TransactionValidation or TransactionValidationError.

type TransactionScanSupportedChain added in v0.7.5

type TransactionScanSupportedChain string

The chain name

const (
	TransactionScanSupportedChainArbitrum    TransactionScanSupportedChain = "arbitrum"
	TransactionScanSupportedChainAvalanche   TransactionScanSupportedChain = "avalanche"
	TransactionScanSupportedChainBase        TransactionScanSupportedChain = "base"
	TransactionScanSupportedChainBaseSepolia TransactionScanSupportedChain = "base-sepolia"
	TransactionScanSupportedChainBsc         TransactionScanSupportedChain = "bsc"
	TransactionScanSupportedChainEthereum    TransactionScanSupportedChain = "ethereum"
	TransactionScanSupportedChainOptimism    TransactionScanSupportedChain = "optimism"
	TransactionScanSupportedChainPolygon     TransactionScanSupportedChain = "polygon"
	TransactionScanSupportedChainZksync      TransactionScanSupportedChain = "zksync"
	TransactionScanSupportedChainZora        TransactionScanSupportedChain = "zora"
	TransactionScanSupportedChainLinea       TransactionScanSupportedChain = "linea"
	TransactionScanSupportedChainBlast       TransactionScanSupportedChain = "blast"
	TransactionScanSupportedChainUnknown     TransactionScanSupportedChain = "unknown"
)

func (TransactionScanSupportedChain) IsKnown added in v0.7.5

func (r TransactionScanSupportedChain) IsKnown() bool

type TransactionSimulation

type TransactionSimulation struct {
	// Account summary for the account address. account address is determined implicit
	// by the `from` field in the transaction request, or explicit by the
	// account_address field in the request.
	AccountSummary TransactionSimulationAccountSummary `json:"account_summary,required"`
	// a dictionary including additional information about each relevant address in the
	// transaction.
	AddressDetails map[string]TransactionSimulationAddressDetail `json:"address_details,required"`
	// dictionary describes the assets differences as a result of this transaction for
	// every involved address
	AssetsDiffs map[string][]AssetDiff `json:"assets_diffs,required"`
	// dictionary describes the exposure differences as a result of this transaction
	// for every involved address (as a result of any approval / setApproval / permit
	// function)
	Exposures map[string][]AddressAssetExposure `json:"exposures,required"`
	// A string indicating if the simulation was successful or not.
	Status TransactionSimulationStatus `json:"status,required"`
	// dictionary represents the usd value each address gained / lost during this
	// transaction
	TotalUsdDiff map[string]UsdDiff `json:"total_usd_diff,required"`
	// a dictionary representing the usd value each address is exposed to, split by
	// spenders
	TotalUsdExposure map[string]map[string]string `json:"total_usd_exposure,required"`
	JSON             transactionSimulationJSON    `json:"-"`
}

func (*TransactionSimulation) UnmarshalJSON

func (r *TransactionSimulation) UnmarshalJSON(data []byte) (err error)

type TransactionSimulationAccountSummary

type TransactionSimulationAccountSummary struct {
	// All assets diffs related to the account address
	AssetsDiffs []AssetDiff `json:"assets_diffs,required"`
	// All assets exposures related to the account address
	Exposures []AddressAssetExposure `json:"exposures,required"`
	// Total usd diff related to the account address
	TotalUsdDiff UsdDiff `json:"total_usd_diff,required"`
	// Total usd exposure related to the account address
	TotalUsdExposure map[string]string                       `json:"total_usd_exposure,required"`
	JSON             transactionSimulationAccountSummaryJSON `json:"-"`
}

Account summary for the account address. account address is determined implicit by the `from` field in the transaction request, or explicit by the account_address field in the request.

func (*TransactionSimulationAccountSummary) UnmarshalJSON

func (r *TransactionSimulationAccountSummary) UnmarshalJSON(data []byte) (err error)

type TransactionSimulationAddressDetail

type TransactionSimulationAddressDetail struct {
	// contains the contract's name if the address is a verified contract
	ContractName string `json:"contract_name"`
	// known name tag for the address
	NameTag string                                 `json:"name_tag"`
	JSON    transactionSimulationAddressDetailJSON `json:"-"`
}

func (*TransactionSimulationAddressDetail) UnmarshalJSON

func (r *TransactionSimulationAddressDetail) UnmarshalJSON(data []byte) (err error)

type TransactionSimulationError added in v0.7.3

type TransactionSimulationError struct {
	// An error message if the simulation failed.
	Error string `json:"error,required"`
	// A string indicating if the simulation was successful or not.
	Status TransactionSimulationErrorStatus `json:"status,required"`
	JSON   transactionSimulationErrorJSON   `json:"-"`
}

func (*TransactionSimulationError) UnmarshalJSON added in v0.7.3

func (r *TransactionSimulationError) UnmarshalJSON(data []byte) (err error)

type TransactionSimulationErrorStatus added in v0.8.0

type TransactionSimulationErrorStatus string

A string indicating if the simulation was successful or not.

const (
	TransactionSimulationErrorStatusError TransactionSimulationErrorStatus = "Error"
)

func (TransactionSimulationErrorStatus) IsKnown added in v0.8.0

type TransactionSimulationStatus added in v0.8.0

type TransactionSimulationStatus string

A string indicating if the simulation was successful or not.

const (
	TransactionSimulationStatusSuccess TransactionSimulationStatus = "Success"
)

func (TransactionSimulationStatus) IsKnown added in v0.8.0

func (r TransactionSimulationStatus) IsKnown() bool

type TransactionValidation

type TransactionValidation struct {
	// A list of features about this transaction explaining the validation.
	Features []TransactionScanFeature `json:"features,required"`
	// An enumeration.
	ResultType TransactionValidationResultType `json:"result_type,required"`
	// A string indicating if the simulation was successful or not.
	Status TransactionValidationStatus `json:"status,required"`
	// A textual classification that can be presented to the user explaining the
	// reason.
	Classification string `json:"classification"`
	// A textual description that can be presented to the user about what this
	// transaction is doing.
	Description string `json:"description"`
	// A textual description about the reasons the transaction was flagged with
	// result_type.
	Reason string                    `json:"reason"`
	JSON   transactionValidationJSON `json:"-"`
}

func (*TransactionValidation) UnmarshalJSON

func (r *TransactionValidation) UnmarshalJSON(data []byte) (err error)

type TransactionValidationError added in v0.7.3

type TransactionValidationError struct {
	// A textual classification that can be presented to the user explaining the
	// reason.
	Classification TransactionValidationErrorClassification `json:"classification,required"`
	// A textual description that can be presented to the user about what this
	// transaction is doing.
	Description TransactionValidationErrorDescription `json:"description,required"`
	// An error message if the validation failed.
	Error string `json:"error,required"`
	// A list of features about this transaction explaining the validation.
	Features []TransactionScanFeature `json:"features,required"`
	// A textual description about the reasons the transaction was flagged with
	// result_type.
	Reason TransactionValidationErrorReason `json:"reason,required"`
	// A string indicating if the transaction is safe to sign or not.
	ResultType TransactionValidationErrorResultType `json:"result_type,required"`
	// A string indicating if the simulation was successful or not.
	Status TransactionValidationErrorStatus `json:"status,required"`
	JSON   transactionValidationErrorJSON   `json:"-"`
}

func (*TransactionValidationError) UnmarshalJSON added in v0.7.3

func (r *TransactionValidationError) UnmarshalJSON(data []byte) (err error)

type TransactionValidationErrorClassification added in v0.7.3

type TransactionValidationErrorClassification string

A textual classification that can be presented to the user explaining the reason.

const (
	TransactionValidationErrorClassificationEmpty TransactionValidationErrorClassification = ""
)

func (TransactionValidationErrorClassification) IsKnown added in v0.7.3

type TransactionValidationErrorDescription added in v0.7.3

type TransactionValidationErrorDescription string

A textual description that can be presented to the user about what this transaction is doing.

const (
	TransactionValidationErrorDescriptionEmpty TransactionValidationErrorDescription = ""
)

func (TransactionValidationErrorDescription) IsKnown added in v0.7.3

type TransactionValidationErrorReason added in v0.7.3

type TransactionValidationErrorReason string

A textual description about the reasons the transaction was flagged with result_type.

const (
	TransactionValidationErrorReasonEmpty TransactionValidationErrorReason = ""
)

func (TransactionValidationErrorReason) IsKnown added in v0.7.3

type TransactionValidationErrorResultType added in v0.7.3

type TransactionValidationErrorResultType string

A string indicating if the transaction is safe to sign or not.

const (
	TransactionValidationErrorResultTypeError TransactionValidationErrorResultType = "Error"
)

func (TransactionValidationErrorResultType) IsKnown added in v0.7.3

type TransactionValidationErrorStatus added in v0.9.1

type TransactionValidationErrorStatus string

A string indicating if the simulation was successful or not.

const (
	TransactionValidationErrorStatusSuccess TransactionValidationErrorStatus = "Success"
)

func (TransactionValidationErrorStatus) IsKnown added in v0.9.1

type TransactionValidationResultType

type TransactionValidationResultType string

An enumeration.

const (
	TransactionValidationResultTypeBenign    TransactionValidationResultType = "Benign"
	TransactionValidationResultTypeWarning   TransactionValidationResultType = "Warning"
	TransactionValidationResultTypeMalicious TransactionValidationResultType = "Malicious"
)

func (TransactionValidationResultType) IsKnown

type TransactionValidationStatus added in v0.9.1

type TransactionValidationStatus string

A string indicating if the simulation was successful or not.

const (
	TransactionValidationStatusSuccess TransactionValidationStatus = "Success"
)

func (TransactionValidationStatus) IsKnown added in v0.9.1

func (r TransactionValidationStatus) IsKnown() bool

type UsdDiff

type UsdDiff struct {
	In    string      `json:"in,required"`
	Out   string      `json:"out,required"`
	Total string      `json:"total,required"`
	JSON  usdDiffJSON `json:"-"`
}

func (*UsdDiff) UnmarshalJSON

func (r *UsdDiff) UnmarshalJSON(data []byte) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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