This is the canonical “from zero to running” guide for an engineer integrating YouthChain into a mobile app. Every step has copy-paste code that runs as-is. By the end of step 7 your app is minting verifiable YCR rewards on-chain when users perform actions.
Before you start, make sure you have Node.js 20+ installed and a code editor open. No private keys to manage yet — we’ll generate test wallets in step 2.

What you’ll build

  • A wallet for the user (generated locally or imported from MetaMask)
  • The wallet funded with test tokens via the faucet
  • Each like / post / share in the app firing an on-chain action that mints YCR
  • Real-time balance display
  • An AMM swap (YCR → YCE) so the user converts rewards into the native token
Estimated time: 30 minutes.

Step 0 — Network basics

Bookmark these — you’ll use them in every call.

Step 1 — Install ethers

Or yarn add ethers@^6 / pnpm add ethers@^6. Works the same in React Native (npm install ethers @ethersproject/shims react-native-get-random-values).

Step 2 — Create or import a wallet

Option A — generate a fresh test wallet (easiest for development)

Option B — connect MetaMask (web/mobile WebView)


Step 3 — Fund the wallet via faucet

The faucet drops 0.1 native YCE + 11,000 YCE token + 1,000 YCR token in a single call. 24h cooldown per address.
Verify the wallet was funded:

Step 4 — Load contract ABIs

ABIs are served as static JSON, CORS-enabled. Your app fetches them at startup.
In production, bundle the ABIs into your app instead of fetching at runtime — they rarely change and you avoid the network hop on cold-start. curl -O + import works.

Step 5 — Read user balances

Display these in your app’s wallet/profile screen.

Step 6 — Record an engagement action

Every social action in your app — post, like, share, comment, watch, NFT mint, tip — should call this endpoint. The indexer signs and submits an on-chain transaction to EngagementOracle.recordAction(), which accumulates pending YCR for the user.

Action weights (whitepaper §9)

Weights are governed on-chain via setYCRMintRate(ActionType, rate) and may change.

Step 7 — Claim pending YCR

Pending YCR is per-user accumulator. The user converts pending → real ERC-20 balance with one transaction:
Show this as a “Claim now” button. Don’t auto-claim on every page load — it costs gas.

Step 8 — AMM swap (YCR → YCE)

Convert reward tokens into the native staking token via the on-chain pool. 2% of input is burned (deflationary).

Step 9 — Real-time updates

For live balance/leaderboard updates without polling, set up a 5-second poll on a single endpoint that returns everything you need:
The /api/mobile/profile/:address endpoint is the single source of truth for everything you’d display in the user’s profile screen.

Step 10 — (Optional) Become a validator

If you want to demo the “phone validating” pattern, the user can bond 10K YCE and have the app sign each block:

Common gotchas

  • Always pass type: 0 to gasLimit in transaction options. EIP-1559 (type: 2) works too but legacy is most reliable across mobile wallets.
  • Never skip the faucet for new wallets. Without 0.1 native YCE, the wallet can’t pay gas to do anything.
  • batchMaxCount: 1 on JsonRpcProvider — the chain accepts JSON-RPC batching but explicit override avoids surprises across versions.
  • Don’t auto-claim YCR. It costs gas every call. Show a button instead.
  • Engagement actions are deduplicated by (user, actionType, targetId) per block. Same like on post_abc123 won’t double-count if fired twice in the same second.

Full working example (single file)

Run with node --experimental-fetch demo.mjs (Node 20+ has fetch native). Expected output after ~10 seconds:

Next steps

Issues or questions: contact the YouthChain dev team. Include your wallet address and the tx hash that’s misbehaving — we trace it from there.