arweave

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = 3 * time.Second
)

Variables

View Source
var DefaultClient = lo.Must(NewClient())

DefaultClient is the default client.

View Source
var DefaultGateways = []string{
	GatewayArweave.String(),
	GatewayARIO.String(),
	GatewayPermagate.String(),
	GatewayLove4Src.String(),
	GatewayARBR.String(),
	GatewayBobInstein.String(),
	GatewayAleko0o.String(),
	GatewaySulapan.String(),
	GatewayFllstck.String(),
	GatewayBicem.String(),
}
View Source
var ErrorNotFound = errors.New("not found")

Functions

func Base64Decode

func Base64Decode(data string) ([]byte, error)

Base64Decode returns the bytes represented by the base64 string.

func Base64Encode

func Base64Encode(data []byte) string

Base64Encode returns the base64 encoding of data.

func GatewayStrings

func GatewayStrings() []string

GatewayStrings returns a slice of all String values of the enum

func PublicKeyToAddress

func PublicKeyToAddress(publicKey string) (string, error)

PublicKeyToAddress returns the arweave address of the owner.

Types

type Block

type Block struct {
	Nonce     string   `json:"nonce"`
	Timestamp int64    `json:"timestamp"`
	Height    int64    `json:"height"`
	Hash      string   `json:"hash"`
	Txs       []string `json:"txs"`
}

Block represents a block on the Arweave network.

type Client

type Client interface {
	GetTransactionData(ctx context.Context, id string) (io.ReadCloser, error)
	GetBlockHeight(ctx context.Context) (blockHeight int64, err error)
	GetBlockByHeight(ctx context.Context, height int64) (block *Block, err error)
	GetTransactionByID(ctx context.Context, id string) (transaction *Transaction, err error)
}

Client is the interface that wraps the Fetch method.

func NewClient

func NewClient(options ...ClientOption) (Client, error)

NewClient creates a new Client with the given options.

type ClientOption

type ClientOption func(client *client) error

ClientOption is the type of the options passed to NewClient.

func WithGateways

func WithGateways(gateways []string) ClientOption

WithGateways sets the client with Arweave gateways.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout sets the client with the given timeout.

type Gateway

type Gateway uint
const (
	GatewayArweave    Gateway = iota // https://arweave.net/
	GatewayARIO                      // https://ar-io.dev/
	GatewayPermagate                 // https://permagate.io/
	GatewayLove4Src                  // https://love4src.com/
	GatewayARBR                      // https://arbr.pro/
	GatewayBobInstein                // https://bobinstein.com/
	GatewayAleko0o                   // https://aleko0o.store/
	GatewaySulapan                   // https://sulapan.com/
	GatewayFllstck                   // https://arweave.fllstck.dev/
	GatewayBicem                     // https://bicem.xyz
	GatewayDilsinay                  // https://dilsinay.online/
	GatewayLostGame                  // https://lostgame.online/
	GatewayKhalDrogo                 // https://khaldrogo.site/
	GatewayDasamuka                  // https://dasamuka.cloud/
	GatewayArendor                   // http://arendor.xyz/
	GatewayVelaryon                  // https://velaryon.xyz/
)

func GatewayString

func GatewayString(s string) (Gateway, error)

GatewayString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func GatewayValues

func GatewayValues() []Gateway

GatewayValues returns all values of the enum

func (Gateway) IsAGateway

func (i Gateway) IsAGateway() bool

IsAGateway returns "true" if the value is listed in the enum definition. "false" otherwise

func (Gateway) String

func (i Gateway) String() string

func (Gateway) Values

func (Gateway) Values() []string

type Network

type Network struct {
	Blocks int64 `json:"blocks"`
}

Network represents the Network information of the Arweave network.

type Tag

type Tag struct {
	Name  string `json:"name" avro:"name"`
	Value string `json:"value" avro:"value"`
}

Tag represents a tag on the Arweave network.

type Transaction

type Transaction struct {
	Format     int       `json:"format"`
	ID         string    `json:"id"`
	Owner      string    `json:"owner"`
	Tags       []Tag     `json:"tags"`
	Target     string    `json:"target"`
	Quantity   string    `json:"quantity"`
	Data       string    `json:"data"`
	DataReader io.Reader `json:"-"`
	DataSize   string    `json:"data_size"`
	DataRoot   string    `json:"data_root"`
	Reward     string    `json:"reward"`
	Signature  string    `json:"signature"`
}

Transaction represents a transaction on the Arweave network.

Directories

Path Synopsis
contract

Jump to

Keyboard shortcuts

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