Documentation
¶
Overview ¶
Package chargeserver contains the Tempo charge server method and verifier. It is usually imported as charge alongside the generic HTTP 402 flow in package server.
Package chargeserver verifies Tempo charge Credentials and builds Tempo charge Challenges for MPP HTTP servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Intent verifies Tempo charge credentials for this method.
Intent *Intent
// Currency is the default token contract address for issued challenges.
Currency string
// Recipient is the default payee address for issued challenges.
Recipient string
// Decimals controls how human-readable amounts are normalized.
Decimals int
// ChainID binds issued challenges to a specific Tempo chain when set.
ChainID int64
// FeePayer enables sponsored transaction flows by default.
FeePayer bool
// FeePayerURL points at a remote co-signer when the server does not sign locally.
FeePayerURL string
// Memo overrides the default attribution memo generation.
Memo string
// SupportedModes limits the credential submission modes advertised to clients.
SupportedModes []tempo.ChargeMode
// RPC overrides the Tempo JSON-RPC client used for verification.
RPC tempo.RPCClient
// RPCURL is used to build an RPC client when RPC is nil.
RPCURL string
// FeePayerSigner co-signs sponsored transactions locally when provided.
FeePayerSigner *temposigner.Signer
// FeePayerPrivateKey constructs FeePayerSigner when FeePayerSigner is nil.
FeePayerPrivateKey string
// FeePayerPrivateKeyEnv loads the fee-payer key from an environment variable when FeePayerPrivateKey is empty.
FeePayerPrivateKeyEnv string
// FeePayerPolicies allowlists the fee tokens this verifier will sponsor.
FeePayerPolicies map[string]FeePayerPolicy
// Store persists replay-protection keys for hash and proof credentials.
Store tempo.Store
}
Config combines the method defaults and intent verification settings used by the high-level Tempo server constructor.
type FeePayerPolicy ¶
type FeePayerPolicy struct {
MaxFeePerGas *big.Int
MaxPriorityFeePerGas *big.Int
MaxTotalFee *big.Int
}
FeePayerPolicy configures sponsored transaction limits for one TIP-20 fee token.
type Intent ¶
type Intent struct {
// contains filtered or unexported fields
}
Intent verifies Tempo charge Credentials and returns Receipts.
func NewIntent ¶
func NewIntent(config IntentConfig) (*Intent, error)
NewIntent constructs a Tempo charge verifier.
type IntentConfig ¶
type IntentConfig struct {
// RPC overrides the Tempo JSON-RPC client used for verification.
RPC tempo.RPCClient
// RPCURL is used to build an RPC client when RPC is nil.
RPCURL string
// FeePayerSigner co-signs sponsored transactions locally when provided.
FeePayerSigner *temposigner.Signer
// FeePayerPrivateKey constructs FeePayerSigner when FeePayerSigner is nil.
FeePayerPrivateKey string
// FeePayerPrivateKeyEnv loads the fee-payer key from an environment variable when FeePayerPrivateKey is empty.
FeePayerPrivateKeyEnv string
// FeePayerPolicies allowlists the fee tokens this verifier will sponsor.
FeePayerPolicies map[string]FeePayerPolicy
// Store persists replay-protection keys for hash and proof credentials.
Store tempo.Store
}
IntentConfig configures Tempo charge verification.
type Method ¶
type Method struct {
// contains filtered or unexported fields
}
Method adapts Tempo charge configuration to the generic server interfaces.
func MethodFromConfig ¶
MethodFromConfig constructs a Tempo charge method from one config struct.
func NewMethod ¶
func NewMethod(config MethodConfig) *Method
NewMethod builds a Tempo server method with request defaults.
func (*Method) BuildChargeRequest ¶
BuildChargeRequest normalizes server charge parameters into Tempo request data.
type MethodConfig ¶
type MethodConfig struct {
// Intent verifies Tempo charge credentials for this method.
Intent *Intent
// Currency is the default token contract address for issued challenges.
Currency string
// Recipient is the default payee address for issued challenges.
Recipient string
// Decimals controls how human-readable amounts are normalized.
Decimals int
// ChainID binds issued challenges to a specific Tempo chain when set.
ChainID int64
// FeePayer enables sponsored transaction flows by default.
FeePayer bool
// FeePayerURL points at a remote co-signer when the server does not sign locally.
FeePayerURL string
// Memo overrides the default attribution memo generation.
Memo string
// SupportedModes limits the credential submission modes advertised to clients.
SupportedModes []tempo.ChargeMode
}
MethodConfig configures a Tempo payment method for server-side charging.