Skip to main content

AruviPaymentGateway API

The main contract for all payment operations.

Address (Sepolia): 0xf2Dd4FC2114e524E9B53d9F608e7484E1CD3271b

Write Functions

send

Send an encrypted payment to a recipient.

function send(
address recipient,
externalEuint64 encryptedAmount,
bytes calldata proof
) external returns (bytes32 paymentId)
ParameterTypeDescription
recipientaddressRecipient wallet address
encryptedAmountbytes32FHE-encrypted amount (externalEuint64)
proofbytesEncryption proof from fhevmjs

Returns: bytes32 — Unique payment ID

Emits: PaymentSent(paymentId, from, to)

Example:

const { handles, inputProof } = await encryptAmount(100_000000n);
const tx = await gateway.send(recipient, handles[0], inputProof);

createRequest

Create a payment request (payment link).

function createRequest(
externalEuint64 encryptedAmount,
bytes calldata proof,
uint256 expiresIn
) external returns (bytes32 requestId)
ParameterTypeDescription
encryptedAmountbytes32Requested amount (encrypted)
proofbytesEncryption proof
expiresInuint256Seconds until expiry (0 = never)

Returns: bytes32 — Unique request ID

Emits: RequestCreated(requestId, requester)


fulfillRequest

Pay a pending payment request.

function fulfillRequest(
bytes32 requestId,
externalEuint64 encryptedAmount,
bytes calldata proof
) external returns (bytes32 paymentId)
ParameterTypeDescription
requestIdbytes32Request to fulfill
encryptedAmountbytes32Payment amount (encrypted)
proofbytesEncryption proof

Emits: RequestFulfilled(requestId, paymentId)

Reverts if:

  • Request doesn't exist
  • Request already fulfilled
  • Request expired
  • Insufficient balance

cancelPaymentRequest

Cancel a request you created.

function cancelPaymentRequest(
uint256 requestId
) external
ParameterTypeDescription
requestIduint256Request to cancel

Emits: PaymentRequestCancelled(requestId)

Reverts if:

  • Request doesn't exist
  • Caller isn't the requester
  • Request already fulfilled

createSubscription

Set up recurring encrypted payments.

function createSubscription(
address recipient,
einput encryptedAmount,
bytes calldata inputProof,
uint256 interval
) external returns (uint256 subscriptionId)
ParameterTypeDescription
recipientaddressPayment recipient
encryptedAmounteinputAmount per period
inputProofbytesEncryption proof
intervaluint256Seconds between payments

Returns: uint256 — Unique subscription ID

Emits: SubscriptionCreated(subscriptionId, payer, recipient, interval)

Common intervals:

  • Daily: 86400
  • Weekly: 604800
  • Monthly: 2592000 (30 days)

executeSubscription

Execute a due subscription payment.

function executeSubscription(
uint256 subscriptionId
) external
ParameterTypeDescription
subscriptionIduint256Subscription to execute

Emits: SubscriptionExecuted(subscriptionId, executionCount)

Reverts if:

  • Subscription doesn't exist
  • Interval hasn't passed since last execution
  • Subscription is cancelled
  • Payer has insufficient balance

Note: Anyone can call this function once the interval has passed.


cancelSubscription

Cancel an active subscription.

function cancelSubscription(
bytes32 subscriptionId
) external
ParameterTypeDescription
subscriptionIdbytes32Subscription to cancel

Emits: SubscriptionCancelled(subscriptionId)

Reverts if:

  • Subscription doesn't exist
  • Caller isn't the subscriber
  • Already cancelled

Read Functions

getPaymentInfo

Get payment details (public info only - amount is encrypted).

function getPaymentInfo(
bytes32 paymentId
) external view returns (
address sender,
address recipient,
address token,
uint256 timestamp,
bool isRefunded
)

Returns:

  • sender: Address that sent the payment
  • recipient: Address that received the payment
  • token: Token contract address (cUSDC wrapper)
  • timestamp: When the payment was made
  • isRefunded: Whether the payment was refunded

getRequestInfo

Get request details (public info only).

function getRequestInfo(
bytes32 requestId
) external view returns (
address requester,
address token,
uint256 createdAt,
uint256 expiresAt,
bool fulfilled
)

Returns:

  • requester: Address that created the request
  • token: Token contract address
  • createdAt: When the request was created
  • expiresAt: When the request expires (0 = never)
  • fulfilled: Whether the request has been paid

getSubscriptionInfo

Get subscription details (public info only).

function getSubscriptionInfo(
bytes32 subscriptionId
) external view returns (
address subscriber,
address recipient,
uint256 interval,
uint256 nextPayment,
bool active
)

Returns:

  • subscriber: Address paying the subscription
  • recipient: Address receiving payments
  • interval: Seconds between payments
  • nextPayment: Timestamp of next due payment
  • active: Whether the subscription is still active

---

### getUserPayments

Get all payments for a user.

```solidity
function getUserPayments(
address user
) external view returns (uint256[] memory paymentIds)

getUserSubscriptions

Get all subscriptions for a user.

function getUserSubscriptions(
address user
) external view returns (uint256[] memory subscriptionIds)

Events

PaymentSent

event PaymentSent(
uint256 indexed paymentId,
address indexed from,
address indexed to
);

PaymentRequestCreated

event PaymentRequestCreated(
uint256 indexed requestId,
address indexed from,
address indexed to
);

PaymentRequestFulfilled

event PaymentRequestFulfilled(
uint256 indexed requestId
);

PaymentRequestCancelled

event PaymentRequestCancelled(
uint256 indexed requestId
);

SubscriptionCreated

event SubscriptionCreated(
uint256 indexed subscriptionId,
address indexed payer,
address indexed recipient,
uint256 interval
);

SubscriptionExecuted

event SubscriptionExecuted(
uint256 indexed subscriptionId,
uint256 executionCount
);

SubscriptionCancelled

event SubscriptionCancelled(
uint256 indexed subscriptionId
);

Enums

PaymentStatus

enum PaymentStatus {
Completed,
RefundRequested,
Refunded
}

RequestStatus

enum RequestStatus {
Pending,
Fulfilled,
Cancelled,
Expired
}

Error Codes

ErrorDescription
InsufficientBalance()Sender doesn't have enough funds
InvalidRecipient()Zero address or invalid recipient
UnauthorizedCaller()Caller not permitted for this action
RequestNotFound()Payment request doesn't exist
SubscriptionNotFound()Subscription doesn't exist
IntervalNotPassed()Too early to execute subscription
AlreadyCancelled()Subscription already cancelled