Skip to main content
RampManager orchestrates the full fiat ↔ token conversion lifecycle. It has two halves: an off-chain half that talks to a pluggable RampProvider for quotes, session creation, and status polling; and an optional on-chain half that talks to a deployed RampSettlement contract to hold tokens in custody during off-ramp flows and record on-ramp attestations. The SDK ships two ready-made providers: ManualRampProvider for local development and testing, and StellarAnchorProvider for production use with any SEP-24-compatible Stellar anchor. For Yellow Card, Flutterwave, Transak, or other providers, implement the RampProvider interface and pass it to the constructor.

Import


Constructor

Constructs a RampManager that uses the same provider for both on-ramp and off-ramp.
RampProvider
required
The RampProvider implementation to use for quotes, session creation, and status polling.
IAdapter
The EVMAdapter or StellarAdapter for on-chain settlement. Required only if you want to call depositOffRamp, confirmOffRampSettlement, refundOffRamp, or recordOnRampSettlement.
string
Address of a deployed RampSettlement contract. Required for on-chain methods. Obtain this address by deploying with TokenFactory.deployRampSettlement().

Static Methods

RampManager.withProviders

Builds a RampManager where on-ramp and off-ramp use independently configured providers. Use this when you want, for example, MoonPay for on-ramp and a Stellar anchor for off-ramp.
RampProvider
required
Provider to use for on-ramp quotes and session creation.
RampProvider
required
Provider to use for off-ramp quotes and session creation.

RampManager.connectAnchor

Convenience factory that constructs a StellarAnchorProvider for you, then wraps it in a RampManager. The anchor’s stellar.toml and SEP-10 handshake are resolved lazily on the first real call — this method does not make any network requests.
string
required
The home domain of the Stellar anchor, e.g. "cowrie.exchange" or "moneygram.com".
StellarExternalSigner
required
A SEP-43-compatible external wallet signer (e.g. Freighter) that signs SEP-10 challenges and off-ramp withdrawal transactions.

Off-Chain Methods

These methods talk to the RampProvider only — they do not touch the chain.

getQuote

Fetches a quote for a fiat ↔ token conversion. The quote includes the exchange rate, fee, and an expiry timestamp. Routes to the on-ramp or off-ramp provider based on input.direction.
"on-ramp" | "off-ramp"
required
Whether the user is buying tokens with fiat ("on-ramp") or selling tokens for fiat ("off-ramp").
string
required
ISO 4217 fiat currency code, e.g. "NGN", "KES", "GHS".
string
required
Token ticker, e.g. "USDC", "USDT".
string
required
ISO 3166-1 alpha-2 country code, e.g. "NG".
string
Fiat amount to convert. Provide either fiatAmount or tokenAmount, not both.
string
Token amount to convert. Provide either fiatAmount or tokenAmount, not both.
Returns: Promise<RampQuote>
string
The fiat amount for this quote (may be calculated if you passed tokenAmount).
string
The token amount for this quote (may be calculated if you passed fiatAmount).
string
The exchange rate applied (tokens per 1 unit of fiat).
string
The provider fee in fiat currency.
number
Unix timestamp after which this quote is no longer valid.

initiateOnRamp

Starts an on-ramp session with the on-ramp provider. Returns a RampSession including a paymentUrl where the user completes the fiat payment. Does not touch the chain.
string
required
Fiat amount the user is paying.
string
required
ISO 4217 code, e.g. "NGN".
string
required
Token the user will receive, e.g. "USDC".
string
required
On-chain address where the tokens will be delivered.
string
required
ISO 3166-1 alpha-2 country code.
string
Optional internal reference string for your records.
Returns: Promise<RampSession>
string
Unique session identifier. Store this to query status or call on-chain methods.
string | undefined
URL where the user completes the fiat payment (on-ramp only).
RampSessionStatus
Initial status. Always "pending" immediately after creation.

initiateOffRamp

Starts an off-ramp session with the off-ramp provider. The user will receive fiat at their specified bank or mobile-money account. Does not touch the chain — call depositOffRamp separately to move tokens to the settlement contract.
string
required
Token amount to sell.
string
required
Token ticker, e.g. "USDC".
string
required
ISO 4217 code, e.g. "NGN".
RampPayoutAccount
required
Bank or mobile-money account for the fiat payout.
string
required
ISO 3166-1 alpha-2 country code.
RampPayoutAccount fields:

getStatus

Polls the provider for the current status of a session.
string
required
The session ID returned from initiateOnRamp or initiateOffRamp.
enum
"pending" · "processing" · "settled" · "failed" · "refunded"

On-Chain Methods

These methods require both an adapter and a settlementAddress to be configured on the RampManager. They throw if either is missing.

depositOffRamp

Deposits tokens into the RampSettlement contract for custody during an off-ramp session. On EVM, you must approve the settlement contract to spend amount of tokenAddress before calling this. On Stellar, the nested transfer is authorized within the same call.
string
required
Session ID from initiateOffRamp.
string
required
Address of the token to deposit.
bigint
required
Amount in wei.

confirmOffRampSettlement

Releases the custodied tokens to the treasury address once the provider confirms the fiat payout was delivered. Typically called by the platform backend after polling getStatus and observing "settled".
string
required
Session ID of the settled off-ramp session.

refundOffRamp

Returns the custodied tokens to the original depositor if the fiat payout failed.
string
required
Session ID of the failed off-ramp session.

recordOnRampSettlement

Records an on-chain attestation that an on-ramp mint/transfer happened for this session. This does not move funds — mint or transfer the tokens separately via your existing token contracts, then record the attestation here for audit trail purposes.
string
required
Session ID of the completed on-ramp session.
string
required
On-chain address that received the minted/transferred tokens.
string
required
Address of the token that was minted.
bigint
required
Amount of tokens minted in wei.

getOffRampDeposit

Returns the on-chain deposit record for an off-ramp session.
string
Address that called depositOffRamp.
string
Token address deposited.
bigint
Deposited amount in wei.
RampSettlementStatus
NONE (0) · PENDING (1) · SETTLED (2) · REFUNDED (3) · RECORDED (4)

getOnRampRecord

Returns the on-chain attestation record for an on-ramp session.

Properties


Provider Reference

ManualRampProvider

A reference RampProvider for local development. Quotes are calculated from statically configured exchange rates; sessions only change status when you call markSettled() or markFailed() in your test code.
Record<string, number>
Map of fiat currency code → tokens per 1 unit of fiat. Defaults to { NGN: 1/1500, KES: 1/150, GHS: 1/15 }.
number
Flat fee in basis points applied to the fiat amount. Defaults to 100 (1%).

StellarAnchorProvider

A production RampProvider backed by any SEP-24 Stellar anchor. Authentication uses SEP-10 (challenge/response signed by the user’s wallet); quotes use SEP-38 where the anchor supports it. The stellar.toml is resolved lazily on first use.
string
required
The anchor’s home domain, e.g. "cowrie.exchange".
StellarExternalSigner
required
A SEP-43-compatible wallet signer. Use RampManager.connectAnchor() as a shortcut to avoid constructing this provider directly.
string
Stellar network passphrase. Defaults to the public testnet passphrase. Override with Networks.PUBLIC for mainnet.
StellarAnchorProvider has been built to the SEP-10/SEP-24/SEP-38 specification but has not yet been tested against a live anchor in production. Verify the SEP-38 asset identifier format and the anchor’s specific status strings before deploying to a mainnet environment.

Full Off-Ramp Flow Example


Type Reference