xscan

package module
v0.0.0-...-9aa8a1e Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 5 Imported by: 0

README

0xScan

testing

💡 About

This module offers an API wrapper for the blockexplorers from the etherscan.io team.

The APIs from the following explorers are supported at the moment:

🚀 Getting started

🧑‍💻 Create a client
package main

import (
    "context"
    xscan "github.com/0xTrackerApp/0xScan"
)

func main() {
    // create empty context interface
    ctx := context.Background()

    // Create a new client
    client := xscan.NewClient(xscan.BscOpts, "<yourApiKey>") // other available options are xscan.EthOpts, xscan.PolygonOpts, etc

    _ = client
}

📜 Licensing

This SDK is released under the MIT-License found in the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EthOpts = &networkOpts{
		endpoint: etherscanUrl,
	}
	BscOpts = &networkOpts{
		endpoint: bscscanUrl,
	}
	PolygonOpts = &networkOpts{
		endpoint: polygonscanUrl,
	}
	FtmOpts = &networkOpts{
		endpoint: ftmscanUrl,
	}
	OptimEthOpts = &networkOpts{
		endpoint: optimetherscanUrl,
	}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(netOpts *networkOpts, apiKey string) *Client

NewClient is a constructor for the Client struct

func (*Client) GetErc20TokenTransfers

func (c *Client) GetErc20TokenTransfers(ctx context.Context, address string, opts *Erc20TokenTransfersOpts) (*Erc20TokenTransfersRes, int, error)

GetErc20TokenTransfers gets a list of "ERC-20 - Token Transfer Events" by Address

type Erc20TokenTransfersOpts

type Erc20TokenTransfersOpts struct {
	// startblock: starting blockNo to retrieve results
	StartBlock string
	// endblock: ending blockNo to retrieve results
	EndBlock string
	// sort order, asc or desc
	Sort string
	// To get paginated results use page=<page number>
	Page string
	// offset=<max records to return>
	Offset string
	// To get transfer events for a specific token contract, include the contractaddress paramete
	ContractAddress string
}

type Erc20TokenTransfersRes

type Erc20TokenTransfersRes struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Result  []Tx   `json:"result"`
}

type Tx

type Tx struct {
	BlockNumber       string `json:"blockNumber"`
	TimeStamp         string `json:"timeStamp"`
	Hash              string `json:"hash"`
	Nonce             string `json:"nonce"`
	BlockHash         string `json:"blockHash"`
	From              string `json:"from"`
	ContractAddress   string `json:"contractAddress"`
	To                string `json:"to"`
	Value             string `json:"value"`
	TokenName         string `json:"tokenName"`
	TokenSymbol       string `json:"tokenSymbol"`
	TokenDecimal      string `json:"tokenDecimal"`
	TransactionIndex  string `json:"transactionIndex"`
	Gas               string `json:"gas"`
	GasPrice          string `json:"gasPrice"`
	GasUsed           string `json:"gasUsed"`
	CumulativeGasUsed string `json:"cumulativeGasUsed"`
	Input             string `json:"input"`
	Confirmations     string `json:"confirmations"`
}

Jump to

Keyboard shortcuts

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