What you’ll learn
- Connecting to the Incentiv Portal and retrieving the user’s account address
- Creating an
ethersprovider and the SDK’sIncentivSigner - Reading on‑chain state from a simple Storage contract
- Triggering a transaction that opens the Portal pop‑up and submits an ERC‑4337 UserOperation
- React hooks for real‑time UI updates
Tech stack
| Tool | Purpose |
|---|---|
| Vite | Development server and bundler |
| React 18 | UI framework |
| TypeScript | Type safety |
| Tailwind CSS | Utility‑first styling |
| ethers v5 | Ethereum RPC + contract ABI bindings |
| Incentiv dApp SDK | Proprietary signing & submission |
Quick start
Note on dependencies You do not need to install@incentiv/dapp-sdkseparately when using this example. Thepackage.jsonalready references the SDK via"file:..", which points one directory up to the local source. If you publish or move the example outside the monorepo, change that line to"@incentiv/dapp-sdk": "^x.y.z"and re‑install.
Configuration
Network and contract settings live insrc/config.ts:
src/App.tsx by modifying:
App anatomy
1. src/App.tsx
handleConnect– asks the SDK for an account address and sets up the provider & signer.handleFetchData– readsstoredValue()andlastSetter()from the Storage contract.handleSubmit– callssetValue(); the SDK opens the Portal for signing and then shows a success/error modal.- A
useEffecthook listens for new blocks and keeps the UI in sync.
2. src/components/Modal.tsx
Reusable modal component used for success/error feedback.
Runtime flow
Troubleshooting
| Symptom | Possible cause & fix |
|---|---|
| Pop‑up opens then closes immediately | The user closed it or rejected the Portal request. |
Popup closed error in console | Same as above – re‑try and approve the Portal prompt. |
Failed to connect wallet | Wrong Portal URL in config.ts or you’re on a different chain. |