A minimal React + TypeScript demo that shows how to integrate the Incentiv dApp SDK in a modern front‑end stack.
ethers
provider and the SDK’s IncentivSigner
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 |
Note on dependencies You do not need to install@incentiv/dapp-sdk
separately when using this example. Thepackage.json
already 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.
src/config.ts
:
src/App.tsx
by modifying:
src/App.tsx
handleConnect
– asks the SDK for an account address and sets up the provider & signer.handleFetchData
– reads storedValue()
and lastSetter()
from the Storage contract.handleSubmit
– calls setValue()
; the SDK opens the Portal for signing and then shows a success/error modal.useEffect
hook listens for new blocks and keeps the UI in sync.src/components/Modal.tsx
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. |