usdc charge method for direct Circle USDC.
v00 implements the EVM EIP-3009 profile and the Solana legacy-SPL profile
from draft-usdc-charge-00. methodDetails.type selects the profile, and
exactly one nested profile object is accepted. Stacks and Gateway register
in profiles/0 without changing the EVM or Solana modules.
Configuration
plug MPP.Plug,
secret_key: "hmac-secret",
realm: "api.example.com",
method: MPP.Methods.USDC,
amount: "1000000",
currency: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
recipient: "0xrecipient",
method_config: %{
"profile" => "evm",
"rpc_url" => "https://ethereum-sepolia-rpc.publicnode.com",
"chain_id" => 11_155_111,
"private_key" => "0x..."
}Solana uses "profile" => "solana", "network" (mainnet or devnet),
and the Circle USDC mint as currency. Set "fee_payer" => true with
"fee_payer_private_key" and "fee_payer_key" when the server pays the
Solana fee.
Server config stays out of the challenge. The advertised methodDetails
are the nested profile object from the draft.
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
challenge_method_details | 1 | Return the nested USDC methodDetails for the configured profile. | charge: value |
verify | 2 | Verify a USDC credential for the selected direct profile. | payload: value, charge: value |
validate_config! | 1 | Validate USDC method_config. Requires profile plus that profile's keys. | config: value |
profiles | 0 | Return implemented USDC profile modules keyed by methodDetails.type. | - |
credential_types | 0 | Return the USDC payload types: authorization and transaction. | - |
method_name | 0 | Return the payment method identifier for USDC. | - |
Summary
Functions
Return the nested USDC methodDetails for the configured profile.
Return the USDC payload types: authorization and transaction.
Return the payment method identifier for USDC.
Return implemented USDC profile modules keyed by methodDetails.type.
Validate USDC method_config. Requires profile plus that profile's keys.
Verify a USDC credential for the selected direct profile.
Functions
@spec challenge_method_details(MPP.Method.intent()) :: map() | nil
@spec challenge_method_details(MPP.Method.intent()) :: map() | nil
Return the nested USDC methodDetails for the configured profile.
Parameters
charge- Charge carrying server method_config in method_details (value)
Returns
Public methodDetails with type and exactly one profile object (map)
# descripex:contract
%{
params: %{
charge: %{
description: "Charge carrying server method_config in method_details",
kind: :value
}
},
returns: %{
type: :map,
description: "Public methodDetails with type and exactly one profile object"
}
}
Return the USDC payload types: authorization and transaction.
# descripex:contract
%{}
@spec method_name() :: String.t()
Return the payment method identifier for USDC.
# descripex:contract
%{}
Return implemented USDC profile modules keyed by methodDetails.type.
# descripex:contract
%{}
Validate USDC method_config. Requires profile plus that profile's keys.
Parameters
config- method_config map, including profile (value)
Returns
:ok, or raises ArgumentError (atom)
# descripex:contract
%{
params: %{
config: %{description: "method_config map, including profile", kind: :value}
},
returns: %{type: :atom, description: "`:ok`, or raises ArgumentError"}
}
@spec verify(map(), MPP.Method.intent()) :: {:ok, MPP.Receipt.t()} | {:error, MPP.Errors.t()}
Verify a USDC credential for the selected direct profile.
Parameters
payload- Credential payload map for the active profile (value)charge- Charge whose method_details select the USDC profile (value)
Returns
{:ok, receipt} or {:error, error} (tagged_tuple)
Errors
:invalid_payload:verification_failed
# descripex:contract
%{
params: %{
payload: %{
description: "Credential payload map for the active profile",
kind: :value
},
charge: %{
description: "Charge whose method_details select the USDC profile",
kind: :value
}
},
errors: [:invalid_payload, :verification_failed],
returns: %{
type: :tagged_tuple,
description: "`{:ok, receipt}` or `{:error, error}`"
}
}