contracts

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package contracts provides contract invocation utilities for the simulation service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePrice

func GeneratePrice(basePrice int64, variancePercent int) int64

GeneratePrice generates a simulated price with some variance.

func GenerateRequestID

func GenerateRequestID() string

GenerateRequestID generates a unique request ID for randomness.

Types

type ContractAddresses

type ContractAddresses struct {
	PriceFeed        string
	RandomnessLog    string
	PaymentHub       string
	AutomationAnchor string
	AppRegistry      string
	Governance       string
}

ContractAddresses holds the addresses of deployed contracts.

type Invoker

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

Invoker provides methods to invoke smart contracts.

func NewInvoker

func NewInvoker(rpcURL string) (*Invoker, error)

NewInvoker creates a new contract invoker.

func (*Invoker) Close

func (inv *Invoker) Close()

Close closes the invoker's connections.

func (*Invoker) GetPriceFeedLatest

func (inv *Invoker) GetPriceFeedLatest(ctx context.Context, symbol string) (map[string]interface{}, error)

GetPriceFeedLatest gets the latest price for a symbol.

func (*Invoker) PayToApp

func (inv *Invoker) PayToApp(ctx context.Context, appID string, amount int64, memo string) (string, error)

PayToApp makes a payment to a MiniApp via PaymentHub. Returns the transaction hash on success.

func (*Invoker) RecordRandomness

func (inv *Invoker) RecordRandomness(ctx context.Context, requestID string) (string, error)

RecordRandomness records a randomness value on-chain. Returns the transaction hash on success.

func (*Invoker) UpdatePriceFeed

func (inv *Invoker) UpdatePriceFeed(ctx context.Context, symbol string, roundID int64, price int64, timestamp uint64) (string, error)

UpdatePriceFeed updates a price feed with new data. Returns the transaction hash on success.

Jump to

Keyboard shortcuts

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