watcher

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package watcher monitors the blockchain for deposits to the platform.

When USDC is sent to the platform address, it automatically credits the sender's agent balance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentChecker

type AgentChecker interface {
	IsAgent(ctx context.Context, address string) bool
}

AgentChecker verifies if an address is a registered agent

type BalanceCreditor

type BalanceCreditor interface {
	Deposit(ctx context.Context, agentAddr, amount, txHash string) error
}

BalanceCreditor credits agent balances

type Config

type Config struct {
	RPCURL          string
	USDCContract    common.Address
	PlatformAddress common.Address
	PollInterval    time.Duration
	StartBlock      uint64 // 0 = latest
}

Config for the deposit watcher

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults

type Watcher

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

Watcher monitors for incoming USDC deposits

func New

func New(cfg Config, creditor BalanceCreditor, checker AgentChecker, logger *slog.Logger) (*Watcher, error)

New creates a new deposit watcher

func (*Watcher) Start

func (w *Watcher) Start(ctx context.Context) error

Start begins watching for deposits

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop stops the watcher

Jump to

Keyboard shortcuts

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