Documentation
¶
Index ¶
- Constants
- Variables
- func NewSVMPayload(transactionBase64 string) map[string]any
- func WithPaymentRecorder(recorder *PaymentRecorder) func(*X402Transport)
- type ClientPaymentOption
- func AcceptUSDCAvalanche() ClientPaymentOption
- func AcceptUSDCAvalancheFuji() ClientPaymentOption
- func AcceptUSDCBase() ClientPaymentOption
- func AcceptUSDCBaseSepolia() ClientPaymentOption
- func AcceptUSDCPolygon() ClientPaymentOption
- func AcceptUSDCPolygonAmoy() ClientPaymentOption
- func AcceptUSDCSolana() ClientPaymentOption
- func AcceptUSDCSolanaDevnet() ClientPaymentOption
- type Config
- type HandlerConfig
- type KeystoreSigner
- type MnemonicSigner
- type MockSigner
- func (m *MockSigner) GetAddress() string
- func (m *MockSigner) GetPaymentOption(network, asset string) *ClientPaymentOption
- func (m *MockSigner) GetPriority() int
- func (m *MockSigner) HasAsset(asset, network string) bool
- func (m *MockSigner) SignPayment(ctx context.Context, req PaymentRequirement) (*PaymentPayload, error)
- func (m *MockSigner) SupportsNetwork(network string) bool
- func (m *MockSigner) WithPriority(priority int) *MockSigner
- type MockSolanaSigner
- func (m *MockSolanaSigner) GetAddress() string
- func (m *MockSolanaSigner) GetPaymentOption(network, asset string) *ClientPaymentOption
- func (m *MockSolanaSigner) GetPriority() int
- func (m *MockSolanaSigner) HasAsset(asset, network string) bool
- func (m *MockSolanaSigner) SignPayment(ctx context.Context, req PaymentRequirement) (*PaymentPayload, error)
- func (m *MockSolanaSigner) SupportsNetwork(network string) bool
- func (m *MockSolanaSigner) WithPriority(priority int) *MockSolanaSigner
- type MultiSignerError
- type PaymentAuthorization
- type PaymentError
- type PaymentEvent
- type PaymentEventType
- type PaymentHandler
- type PaymentPayload
- type PaymentPayloadData
- type PaymentRecorder
- func (r *PaymentRecorder) Clear()
- func (r *PaymentRecorder) FailedPayments() []PaymentEvent
- func (r *PaymentRecorder) GetEvents() []PaymentEvent
- func (r *PaymentRecorder) LastPayment() *PaymentEvent
- func (r *PaymentRecorder) PaymentCount() int
- func (r *PaymentRecorder) Record(event PaymentEvent)
- func (r *PaymentRecorder) SuccessfulPayments() []PaymentEvent
- func (r *PaymentRecorder) TotalAmount() string
- type PaymentRequirement
- type PaymentRequirementsResponse
- type PaymentSigner
- type PrivateKeySigner
- func (s *PrivateKeySigner) GetAddress() string
- func (s *PrivateKeySigner) GetPaymentOption(network, asset string) *ClientPaymentOption
- func (s *PrivateKeySigner) GetPriority() int
- func (s *PrivateKeySigner) HasAsset(asset, network string) bool
- func (s *PrivateKeySigner) SignPayment(ctx context.Context, req PaymentRequirement) (*PaymentPayload, error)
- func (s *PrivateKeySigner) SupportsNetwork(network string) bool
- func (s *PrivateKeySigner) WithPriority(priority int) *PrivateKeySigner
- type SettlementResponse
- type SignerFailure
- type SolanaPrivateKeySigner
- func (s *SolanaPrivateKeySigner) GetAddress() string
- func (s *SolanaPrivateKeySigner) GetPaymentOption(network, asset string) *ClientPaymentOption
- func (s *SolanaPrivateKeySigner) GetPriority() int
- func (s *SolanaPrivateKeySigner) HasAsset(asset, network string) bool
- func (s *SolanaPrivateKeySigner) SignPayment(ctx context.Context, req PaymentRequirement) (*PaymentPayload, error)
- func (s *SolanaPrivateKeySigner) SupportsNetwork(network string) bool
- func (s *SolanaPrivateKeySigner) WithPriority(priority int) *SolanaPrivateKeySigner
- type X402Transport
- func (t *X402Transport) Close() error
- func (t *X402Transport) GetSessionId() string
- func (t *X402Transport) SendNotification(ctx context.Context, notification mcp.JSONRPCNotification) error
- func (t *X402Transport) SendRequest(ctx context.Context, request transport.JSONRPCRequest) (*transport.JSONRPCResponse, error)
- func (t *X402Transport) SetNotificationHandler(handler func(mcp.JSONRPCNotification))
- func (t *X402Transport) SetProtocolVersion(version string)
- func (t *X402Transport) SetRequestHandler(handler transport.RequestHandler)
- func (t *X402Transport) Start(ctx context.Context) error
Constants ¶
const ( // EVM Mainnet USDC addresses USDCAddressBase = "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913" // Base mainnet USDCAddressPolygon = "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359" // Polygon mainnet USDCAddressAvalanche = "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e" // Avalanche C-Chain // EVM Testnet USDC addresses USDCAddressBaseSepolia = "0x036cbd53842c5426634e7929541ec2318f3dcf7e" // Base Sepolia USDCAddressPolygonAmoy = "0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582" // Polygon Amoy USDCAddressAvalancheFuji = "0x5425890298aed601595a70ab815c96711a31bc65" // Avalanche Fuji // Solana USDC mint addresses USDCMintSolana = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" // Solana mainnet USDCMintSolanaDevnet = "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU" // Solana devnet )
USDC contract addresses (lowercase for consistency)
Variables ¶
var ( // Payment errors ErrPaymentRequired = errors.New("payment required") ErrNoAcceptablePayment = errors.New("no acceptable payment method found") ErrSigningFailed = errors.New("failed to sign payment") ErrInvalidPaymentReqs = errors.New("invalid payment requirements") // Network errors ErrUnsupportedNetwork = errors.New("unsupported network") ErrUnsupportedAsset = errors.New("unsupported asset") // Signer errors ErrInvalidPrivateKey = errors.New("invalid private key") ErrInvalidMnemonic = errors.New("invalid mnemonic phrase") ErrInvalidKeystore = errors.New("invalid keystore file") ErrWrongPassword = errors.New("wrong keystore password") ErrNoSignerConfigured = errors.New("no payment signer configured") ErrNoViablePaymentOption = errors.New("no viable payment option found across all signers") )
var ErrSessionTerminated = errors.New("session terminated (404). need to re-initialize")
ErrSessionTerminated is returned when a session is terminated (404)
Functions ¶
func NewSVMPayload ¶ added in v0.8.0
NewSVMPayload creates a Solana (SVM) payment payload with a base64-encoded transaction
func WithPaymentRecorder ¶
func WithPaymentRecorder(recorder *PaymentRecorder) func(*X402Transport)
WithPaymentRecorder adds a payment recorder for testing
Types ¶
type ClientPaymentOption ¶ added in v0.4.0
type ClientPaymentOption struct {
PaymentRequirement
// Client-specific fields
Priority int `json:"-"` // Lower number = higher priority
MaxAmount string `json:"-"` // Client's max willing to pay with this option
MinBalance string `json:"-"` // Don't use if balance falls below this
ChainID *big.Int `json:"-"` // Chain ID for signing (EVM networks)
NetworkID string `json:"-"` // Network ID for non-EVM networks (e.g., "mainnet-beta", "devnet")
}
ClientPaymentOption represents a payment method the client accepts
func AcceptUSDCAvalanche ¶ added in v0.8.2
func AcceptUSDCAvalanche() ClientPaymentOption
AcceptUSDCAvalanche creates a client payment option for USDC on Avalanche C-Chain mainnet
func AcceptUSDCAvalancheFuji ¶ added in v0.8.2
func AcceptUSDCAvalancheFuji() ClientPaymentOption
AcceptUSDCAvalancheFuji creates a client payment option for USDC on Avalanche Fuji testnet
func AcceptUSDCBase ¶ added in v0.4.0
func AcceptUSDCBase() ClientPaymentOption
AcceptUSDCBase creates a client payment option for USDC on Base mainnet
func AcceptUSDCBaseSepolia ¶ added in v0.4.0
func AcceptUSDCBaseSepolia() ClientPaymentOption
AcceptUSDCBaseSepolia creates a client payment option for USDC on Base Sepolia testnet
func AcceptUSDCPolygon ¶ added in v0.8.2
func AcceptUSDCPolygon() ClientPaymentOption
AcceptUSDCPolygon creates a client payment option for USDC on Polygon mainnet
func AcceptUSDCPolygonAmoy ¶ added in v0.8.2
func AcceptUSDCPolygonAmoy() ClientPaymentOption
AcceptUSDCPolygonAmoy creates a client payment option for USDC on Polygon Amoy testnet
func AcceptUSDCSolana ¶ added in v0.8.0
func AcceptUSDCSolana() ClientPaymentOption
AcceptUSDCSolana creates a client payment option for USDC on Solana mainnet
func AcceptUSDCSolanaDevnet ¶ added in v0.8.0
func AcceptUSDCSolanaDevnet() ClientPaymentOption
AcceptUSDCSolanaDevnet creates a client payment option for USDC on Solana devnet
func (ClientPaymentOption) WithMaxAmount ¶ added in v0.4.0
func (opt ClientPaymentOption) WithMaxAmount(amount string) ClientPaymentOption
WithMaxAmount sets the maximum amount the client is willing to pay with this option
func (ClientPaymentOption) WithMinBalance ¶ added in v0.4.0
func (opt ClientPaymentOption) WithMinBalance(amount string) ClientPaymentOption
WithMinBalance sets the minimum balance to maintain (won't use if balance would fall below)
func (ClientPaymentOption) WithPriority ¶ added in v0.4.0
func (opt ClientPaymentOption) WithPriority(p int) ClientPaymentOption
WithPriority sets the priority for this payment option
type Config ¶
type Config struct {
ServerURL string
Signer PaymentSigner // DEPRECATED: Use Signers instead
Signers []PaymentSigner // Multiple signers with priority
PaymentCallback func(amount *big.Int, resource string) bool
HTTPClient *http.Client
OnPaymentAttempt func(PaymentEvent)
OnPaymentSuccess func(PaymentEvent)
OnPaymentFailure func(PaymentEvent, error)
OnSignerAttempt func(PaymentEvent) // Per-signer attempt callback
}
Config configures the X402Transport
type HandlerConfig ¶
type HandlerConfig struct {
PaymentCallback func(amount *big.Int, resource string) bool
OnSignerAttempt func(PaymentEvent)
}
HandlerConfig configures the payment handler
type KeystoreSigner ¶
type KeystoreSigner struct {
*PrivateKeySigner
}
KeystoreSigner signs with a key from an encrypted keystore file
func NewKeystoreSigner ¶
func NewKeystoreSigner(keystoreJSON []byte, password string, options ...ClientPaymentOption) (*KeystoreSigner, error)
NewKeystoreSigner creates a signer from an encrypted keystore JSON with explicit payment options
func (*KeystoreSigner) GetPriority ¶ added in v0.7.0
func (s *KeystoreSigner) GetPriority() int
GetPriority returns the signer's priority
func (*KeystoreSigner) WithPriority ¶ added in v0.7.0
func (s *KeystoreSigner) WithPriority(priority int) *KeystoreSigner
WithPriority sets the signer's priority
type MnemonicSigner ¶
type MnemonicSigner struct {
*PrivateKeySigner
}
MnemonicSigner signs with a key derived from a mnemonic phrase
func NewMnemonicSigner ¶
func NewMnemonicSigner(mnemonic string, derivationPath string, options ...ClientPaymentOption) (*MnemonicSigner, error)
NewMnemonicSigner creates a signer from a BIP-39 mnemonic phrase with explicit payment options
func (*MnemonicSigner) GetPriority ¶ added in v0.7.0
func (s *MnemonicSigner) GetPriority() int
GetPriority returns the signer's priority
func (*MnemonicSigner) WithPriority ¶ added in v0.7.0
func (s *MnemonicSigner) WithPriority(priority int) *MnemonicSigner
WithPriority sets the signer's priority
type MockSigner ¶
type MockSigner struct {
// contains filtered or unexported fields
}
MockSigner is a test signer that generates fake signatures
func NewMockSigner ¶
func NewMockSigner(address string, options ...ClientPaymentOption) *MockSigner
NewMockSigner creates a mock signer for testing with explicit payment options
func (*MockSigner) GetAddress ¶
func (m *MockSigner) GetAddress() string
GetAddress returns the mock signer's address
func (*MockSigner) GetPaymentOption ¶ added in v0.4.0
func (m *MockSigner) GetPaymentOption(network, asset string) *ClientPaymentOption
GetPaymentOption returns the client payment option that matches the network and asset
func (*MockSigner) GetPriority ¶ added in v0.7.0
func (m *MockSigner) GetPriority() int
GetPriority returns the signer's priority
func (*MockSigner) HasAsset ¶
func (m *MockSigner) HasAsset(asset, network string) bool
HasAsset returns true if the mock signer has the given asset on the network
func (*MockSigner) SignPayment ¶
func (m *MockSigner) SignPayment(ctx context.Context, req PaymentRequirement) (*PaymentPayload, error)
SignPayment creates a mock payment signature for testing
func (*MockSigner) SupportsNetwork ¶
func (m *MockSigner) SupportsNetwork(network string) bool
SupportsNetwork returns true if the mock signer supports the given network
func (*MockSigner) WithPriority ¶ added in v0.7.0
func (m *MockSigner) WithPriority(priority int) *MockSigner
WithPriority sets the signer's priority
type MockSolanaSigner ¶ added in v0.8.0
type MockSolanaSigner struct {
// contains filtered or unexported fields
}
func NewMockSolanaSigner ¶ added in v0.8.0
func NewMockSolanaSigner(address string, options ...ClientPaymentOption) *MockSolanaSigner
NewMockSolanaSigner creates a mock Solana signer for testing with explicit payment options
func (*MockSolanaSigner) GetAddress ¶ added in v0.8.0
func (m *MockSolanaSigner) GetAddress() string
GetAddress returns the mock signer's address
func (*MockSolanaSigner) GetPaymentOption ¶ added in v0.8.0
func (m *MockSolanaSigner) GetPaymentOption(network, asset string) *ClientPaymentOption
GetPaymentOption returns the client payment option that matches the network and asset
func (*MockSolanaSigner) GetPriority ¶ added in v0.8.0
func (m *MockSolanaSigner) GetPriority() int
GetPriority returns the mock signer's priority (lower = higher precedence)
func (*MockSolanaSigner) HasAsset ¶ added in v0.8.0
func (m *MockSolanaSigner) HasAsset(asset, network string) bool
HasAsset returns true if the mock signer has the given asset on the network
func (*MockSolanaSigner) SignPayment ¶ added in v0.8.0
func (m *MockSolanaSigner) SignPayment(ctx context.Context, req PaymentRequirement) (*PaymentPayload, error)
SignPayment creates a mock payment signature for testing
func (*MockSolanaSigner) SupportsNetwork ¶ added in v0.8.0
func (m *MockSolanaSigner) SupportsNetwork(network string) bool
SupportsNetwork returns true if the mock signer supports the given network
func (*MockSolanaSigner) WithPriority ¶ added in v0.8.0
func (m *MockSolanaSigner) WithPriority(priority int) *MockSolanaSigner
WithPriority sets the mock signer's priority for multi-signer configurations
type MultiSignerError ¶ added in v0.7.0
type MultiSignerError struct {
Message string
SignerFailures []SignerFailure
}
MultiSignerError aggregates failures from multiple signers
func (*MultiSignerError) Error ¶ added in v0.7.0
func (e *MultiSignerError) Error() string
Error returns the formatted error message with details from all signer failures
func (*MultiSignerError) Unwrap ¶ added in v0.7.0
func (e *MultiSignerError) Unwrap() error
Unwrap returns the first signer's wrapped error if available
type PaymentAuthorization ¶
type PaymentAuthorization struct {
From string `json:"from"`
To string `json:"to"`
Value string `json:"value"`
ValidAfter string `json:"validAfter"`
ValidBefore string `json:"validBefore"`
Nonce string `json:"nonce"`
}
PaymentAuthorization contains EIP-3009 authorization data
type PaymentError ¶
type PaymentError struct {
Code string
Message string
Resource string
Amount string
Network string
Wrapped error
}
PaymentError provides detailed payment error information
func NewPaymentError ¶
func NewPaymentError(code, message, resource, amount, network string, wrapped error) *PaymentError
NewPaymentError creates a new PaymentError
func (*PaymentError) Error ¶
func (e *PaymentError) Error() string
Error returns the formatted error message
func (*PaymentError) Unwrap ¶
func (e *PaymentError) Unwrap() error
Unwrap returns the underlying wrapped error
type PaymentEvent ¶
type PaymentEvent struct {
Type PaymentEventType
Resource string
Method string
Amount *big.Int
Network string
Asset string
Recipient string
Transaction string
Error error
Timestamp int64
SignerIndex int // Position in signers array
SignerPriority int // Signer's priority value
SignerAddress string // Signer's address
AttemptNumber int // Sequential attempt count
}
PaymentEvent represents a payment lifecycle event
type PaymentEventType ¶
type PaymentEventType string
PaymentEventType represents types of payment events
const ( PaymentEventAttempt PaymentEventType = "attempt" PaymentEventSuccess PaymentEventType = "success" PaymentEventFailure PaymentEventType = "failure" PaymentEventSignerAttempt PaymentEventType = "signer_attempt" PaymentEventSignerSuccess PaymentEventType = "signer_success" PaymentEventSignerFailure PaymentEventType = "signer_failure" )
type PaymentHandler ¶
type PaymentHandler struct {
// contains filtered or unexported fields
}
PaymentHandler handles x402 payment operations
func NewPaymentHandler ¶
func NewPaymentHandler(signer PaymentSigner, config *HandlerConfig) (*PaymentHandler, error)
NewPaymentHandler creates a new payment handler (backward compatibility)
func NewPaymentHandlerMulti ¶ added in v0.7.0
func NewPaymentHandlerMulti(signers []PaymentSigner, config *HandlerConfig) (*PaymentHandler, error)
NewPaymentHandlerMulti creates a new payment handler with multiple signers
func (*PaymentHandler) CreatePayment ¶
func (h *PaymentHandler) CreatePayment(ctx context.Context, reqs PaymentRequirementsResponse) (*PaymentPayload, error)
CreatePayment creates a signed payment for the given requirements
func (*PaymentHandler) ShouldPay ¶
func (h *PaymentHandler) ShouldPay(req PaymentRequirement) (bool, error)
ShouldPay determines if a payment should be made
type PaymentPayload ¶
type PaymentPayload struct {
X402Version int `json:"x402Version"`
Scheme string `json:"scheme"`
Network string `json:"network"`
Payload any `json:"payload"`
}
PaymentPayload is the signed payment sent in X-PAYMENT header
func (*PaymentPayload) Encode ¶
func (p *PaymentPayload) Encode() string
Encode encodes the payment payload as base64 for the X-PAYMENT header
type PaymentPayloadData ¶
type PaymentPayloadData struct {
Signature string `json:"signature"`
Authorization PaymentAuthorization `json:"authorization"`
}
PaymentPayloadData contains the signature and authorization
type PaymentRecorder ¶
type PaymentRecorder struct {
// contains filtered or unexported fields
}
PaymentRecorder records payment events for testing
func NewPaymentRecorder ¶
func NewPaymentRecorder() *PaymentRecorder
NewPaymentRecorder creates a new payment recorder
func (*PaymentRecorder) FailedPayments ¶
func (r *PaymentRecorder) FailedPayments() []PaymentEvent
FailedPayments returns only failed payment events (returns deep copies)
func (*PaymentRecorder) GetEvents ¶
func (r *PaymentRecorder) GetEvents() []PaymentEvent
GetEvents returns all recorded events (returns deep copies to prevent mutations)
func (*PaymentRecorder) LastPayment ¶
func (r *PaymentRecorder) LastPayment() *PaymentEvent
LastPayment returns the most recent payment event (returns a copy to prevent mutations)
func (*PaymentRecorder) PaymentCount ¶
func (r *PaymentRecorder) PaymentCount() int
PaymentCount returns the number of recorded payments
func (*PaymentRecorder) Record ¶
func (r *PaymentRecorder) Record(event PaymentEvent)
Record records a payment event
func (*PaymentRecorder) SuccessfulPayments ¶
func (r *PaymentRecorder) SuccessfulPayments() []PaymentEvent
SuccessfulPayments returns only successful payment events (returns deep copies)
func (*PaymentRecorder) TotalAmount ¶
func (r *PaymentRecorder) TotalAmount() string
TotalAmount returns the total amount of all successful payments
type PaymentRequirement ¶
type PaymentRequirement struct {
Scheme string `json:"scheme"`
Network string `json:"network"`
MaxAmountRequired string `json:"maxAmountRequired"`
Asset string `json:"asset"`
PayTo string `json:"payTo"`
Resource string `json:"resource"`
Description string `json:"description"`
MimeType string `json:"mimeType,omitempty"`
OutputSchema interface{} `json:"outputSchema,omitempty"`
MaxTimeoutSeconds int `json:"maxTimeoutSeconds"`
Extra map[string]string `json:"extra,omitempty"`
}
PaymentRequirement represents a payment method from the server
type PaymentRequirementsResponse ¶
type PaymentRequirementsResponse struct {
X402Version int `json:"x402Version"`
Error string `json:"error"`
Accepts []PaymentRequirement `json:"accepts"`
}
PaymentRequirementsResponse is the 402 response body
type PaymentSigner ¶
type PaymentSigner interface {
// SignPayment signs a payment authorization for the given requirement
SignPayment(ctx context.Context, req PaymentRequirement) (*PaymentPayload, error)
// GetAddress returns the signer's address
GetAddress() string
// SupportsNetwork returns true if the signer supports the given network
SupportsNetwork(network string) bool
// HasAsset returns true if the signer has the given asset on the network
HasAsset(asset, network string) bool
// GetPaymentOption returns the client payment option that matches the network and asset
GetPaymentOption(network, asset string) *ClientPaymentOption
// GetPriority returns the signer's priority (lower = higher precedence)
GetPriority() int
}
PaymentSigner signs x402 payment authorizations
type PrivateKeySigner ¶
type PrivateKeySigner struct {
// contains filtered or unexported fields
}
PrivateKeySigner signs with a raw private key
func NewPrivateKeySigner ¶
func NewPrivateKeySigner(privateKeyHex string, options ...ClientPaymentOption) (*PrivateKeySigner, error)
NewPrivateKeySigner creates a signer from a hex-encoded private key with explicit payment options
func (*PrivateKeySigner) GetAddress ¶
func (s *PrivateKeySigner) GetAddress() string
GetAddress returns the signer's Ethereum address
func (*PrivateKeySigner) GetPaymentOption ¶ added in v0.4.0
func (s *PrivateKeySigner) GetPaymentOption(network, asset string) *ClientPaymentOption
GetPaymentOption returns the client payment option that matches the network and asset
func (*PrivateKeySigner) GetPriority ¶ added in v0.7.0
func (s *PrivateKeySigner) GetPriority() int
GetPriority returns the signer's priority (lower value = higher priority)
func (*PrivateKeySigner) HasAsset ¶
func (s *PrivateKeySigner) HasAsset(asset, network string) bool
HasAsset returns true if the signer has the given asset on the network
func (*PrivateKeySigner) SignPayment ¶
func (s *PrivateKeySigner) SignPayment(ctx context.Context, req PaymentRequirement) (*PaymentPayload, error)
SignPayment signs a payment authorization for the given requirement
func (*PrivateKeySigner) SupportsNetwork ¶
func (s *PrivateKeySigner) SupportsNetwork(network string) bool
SupportsNetwork returns true if the signer supports the given network
func (*PrivateKeySigner) WithPriority ¶ added in v0.7.0
func (s *PrivateKeySigner) WithPriority(priority int) *PrivateKeySigner
WithPriority sets the signer's priority for multi-signer configurations
type SettlementResponse ¶
type SettlementResponse struct {
Success bool `json:"success"`
Transaction string `json:"transaction"`
Network string `json:"network"`
Payer string `json:"payer"`
ErrorReason string `json:"errorReason,omitempty"`
}
SettlementResponse represents the X-PAYMENT-RESPONSE header content
type SignerFailure ¶ added in v0.7.0
type SignerFailure struct {
SignerIndex int
SignerPriority int
SignerAddress string
Reason string
WrappedError error
}
SignerFailure represents a single signer's failure details
type SolanaPrivateKeySigner ¶ added in v0.8.0
type SolanaPrivateKeySigner struct {
// contains filtered or unexported fields
}
func NewSolanaPrivateKeySigner ¶ added in v0.8.0
func NewSolanaPrivateKeySigner(privateKeyBase58 string, options ...ClientPaymentOption) (*SolanaPrivateKeySigner, error)
NewSolanaPrivateKeySigner creates a signer from a base58-encoded Solana private key with explicit payment options
func NewSolanaPrivateKeySignerFromFile ¶ added in v0.8.0
func NewSolanaPrivateKeySignerFromFile(filepath string, options ...ClientPaymentOption) (*SolanaPrivateKeySigner, error)
NewSolanaPrivateKeySignerFromFile creates a signer from a Solana keypair file with explicit payment options
func (*SolanaPrivateKeySigner) GetAddress ¶ added in v0.8.0
func (s *SolanaPrivateKeySigner) GetAddress() string
GetAddress returns the signer's Solana address
func (*SolanaPrivateKeySigner) GetPaymentOption ¶ added in v0.8.0
func (s *SolanaPrivateKeySigner) GetPaymentOption(network, asset string) *ClientPaymentOption
GetPaymentOption returns the client payment option that matches the network and asset
func (*SolanaPrivateKeySigner) GetPriority ¶ added in v0.8.0
func (s *SolanaPrivateKeySigner) GetPriority() int
GetPriority returns the signer's priority (lower = higher precedence)
func (*SolanaPrivateKeySigner) HasAsset ¶ added in v0.8.0
func (s *SolanaPrivateKeySigner) HasAsset(asset, network string) bool
HasAsset returns true if the signer has the given asset on the network
func (*SolanaPrivateKeySigner) SignPayment ¶ added in v0.8.0
func (s *SolanaPrivateKeySigner) SignPayment(ctx context.Context, req PaymentRequirement) (*PaymentPayload, error)
SignPayment signs a payment authorization for the given requirement
func (*SolanaPrivateKeySigner) SupportsNetwork ¶ added in v0.8.0
func (s *SolanaPrivateKeySigner) SupportsNetwork(network string) bool
SupportsNetwork returns true if the signer supports the given network
func (*SolanaPrivateKeySigner) WithPriority ¶ added in v0.8.0
func (s *SolanaPrivateKeySigner) WithPriority(priority int) *SolanaPrivateKeySigner
WithPriority sets the signer's priority for multi-signer configurations
type X402Transport ¶
type X402Transport struct {
// contains filtered or unexported fields
}
X402Transport implements transport.Interface with x402 payment support It is based on StreamableHTTP with added x402 payment handling
func (*X402Transport) Close ¶
func (t *X402Transport) Close() error
Close implements transport.Interface
func (*X402Transport) GetSessionId ¶
func (t *X402Transport) GetSessionId() string
GetSessionId implements transport.Interface
func (*X402Transport) SendNotification ¶
func (t *X402Transport) SendNotification(ctx context.Context, notification mcp.JSONRPCNotification) error
SendNotification implements transport.Interface
func (*X402Transport) SendRequest ¶
func (t *X402Transport) SendRequest(ctx context.Context, request transport.JSONRPCRequest) (*transport.JSONRPCResponse, error)
SendRequest implements transport.Interface with x402 payment handling
func (*X402Transport) SetNotificationHandler ¶
func (t *X402Transport) SetNotificationHandler(handler func(mcp.JSONRPCNotification))
SetNotificationHandler implements transport.Interface
func (*X402Transport) SetProtocolVersion ¶
func (t *X402Transport) SetProtocolVersion(version string)
SetProtocolVersion implements transport.Interface
func (*X402Transport) SetRequestHandler ¶
func (t *X402Transport) SetRequestHandler(handler transport.RequestHandler)
SetRequestHandler implements transport.Interface