Reference

Smart Contract Architecture

The ArcSocialPay contract: what it does, its functions and events, and the design choices behind it.

Overview

ArcSocialPay is a single Solidity file (version 0.8.28, no imports) deployed on Arc Mainnet. It moves USDC from a payer to a recipient and records a memo or a post id as an event. Plain ERC-20 transfers cannot carry that information.

ArcSocialPay

Arc Explorer

0x3b61FC789342B02Ae9DA3Bcece910AFaAd40bf54

Payments and tips with an onchain memo. Holds no funds, no fees, not upgradeable.

In this repository: contracts/ArcSocialPay.sol, src/contracts/arcSocialPay.ts

Create2Factory

Arc Explorer

0x375Fb60CA0ba2f3bfBfE95eb122ecF087bD1334d

Deployment infrastructure for deterministic addresses. The app does not call it.

In this repository: contracts/script/Create2Factory.sol

Verification status

A live read of the contract on Arc confirmed that VERSION is 1.0.0, usdc() is the Arc USDC address and paused() is false. Whether the source is published as verified on Arc Explorer was not confirmed when this page was written. Check the Contract tab on the explorer.

Design choices

  • No custody. Every call pulls USDC with transferFrom and sends it to the recipient in the same call. The contract is meant to hold zero USDC.
  • No fees, no upgrade proxy, no delegatecall, no self-destruct.
  • Only the caller can spend their own allowance, because the payer is always msg.sender.
  • Reentrancy lock on every state-changing flow.
  • A transfer helper that also works with tokens that return no boolean, and reverts on a false return.
  • Social data (posts, chats, profiles) stays off-chain. Events are the only onchain record, for indexing.
  1. 1

    Connect

    Your wallet connects to Arc Mainnet.

  2. 2

    Approve

    USDC allowance for ArcSocialPay, up to the limit you chose.

  3. 3

    Pay

    pay(recipient, amount, memo) pulls USDC from you.

  4. 4

    Deliver

    The contract forwards it to the recipient in the same call.

  5. 5

    Confirm

    A Payment event is emitted and the receipt is verified.

Functions

FunctionWhoWhat it does
pay(recipient, amount, memo)AnyonePulls amount USDC from the caller to recipient and emits Payment. Memo up to 280 bytes.
tip(recipient, amount, postId)AnyoneSame transfer, emits Tip with an off-chain post id of up to 128 bytes.
myAllowance(account)ViewUSDC allowance account gave this contract.
canPay(account, amount)ViewTrue if not paused, amount is above zero, and balance and allowance cover it.
usdc(), owner(), pendingOwner(), paused(), VERSIONViewConfiguration and state.
pause(), unpause()OwnerStops or resumes pay and tip. Funds are never held, so a pause cannot freeze user money.
proposeOwner, acceptOwnership, cancelOwnershipTransferOwner / pending ownerTwo-step ownership transfer so a mistyped address cannot lock the contract.
rescueERC20(token, to, amount), rescueNative(to)OwnerRecover tokens or native gas that were sent to the contract by mistake.

Direct native transfers to the contract revert with DIRECT_TRANSFERS_DISABLED.

Events

event Payment(address indexed sender, address indexed recipient, uint256 amount, string memo);
event Tip(address indexed sender, address indexed recipient, uint256 amount, string postId);
event OwnershipProposed(address indexed currentOwner, address indexed proposedOwner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event Paused(address indexed account);
event Unpaused(address indexed account);
event Rescued(address indexed token, address indexed to, uint256 amount);

amount is in 6-decimal USDC base units. For example, 1 USDC is 1000000.

Revert reasons

ReasonMeaning
RECIPIENT_ZERO, RECIPIENT_SELF, RECIPIENT_SELF_CONTRACT, RECIPIENT_USDC_CONTRACTThe recipient is the zero address, yourself, this contract or the USDC contract.
AMOUNT_ZEROAmount must be above zero.
MEMO_TOO_LONG, POST_ID_TOO_LONGOver 280 or 128 bytes.
PAUSEDThe owner paused new payments.
REENTRANTA nested call was blocked.
NOT_OWNER, NOT_PENDING_OWNERThe caller lacks the role for that call.

Tests

The Foundry suite has 74 tests: unit tests for payments, tips, reverts, pause, ownership, rescue and reentrancy, plus two invariants that run 256 randomised sequences each. The invariants check that the contract never holds USDC and that total USDC is conserved. All passed in the most recent run.

forge build
forge test

Tests are not an audit. See Security Documentation for what has and has not been reviewed.

Found something unclear or out of date? Open an issue on GitHub.