Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions session-keys-subscription-payments/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

contracts/lib
contracts/cache
contracts/zkout
contracts/out
33 changes: 33 additions & 0 deletions session-keys-subscription-payments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Abstract Global Wallet with Next.js

This example showcases how to use the Abstract Global Wallet react SDK inside a [Next.js](https://nextjs.org/) application.

## Local Development

1. Get a copy of the `agw-nextjs` example directory from the Abstract Examples repository:

```bash
mkdir -p agw-nextjs && curl -L https://codeload.github.com/Abstract-Foundation/examples/tar.gz/main | tar -xz --strip=2 -C agw-nextjs examples-main/agw-nextjs && cd agw-nextjs
```

2. Install dependencies

```bash
npm install
```

3. Run the development server

```bash
npm run dev
```

Visit [http://localhost:3000](http://localhost:3000) to see the app.

## Useful Links

- [Docs](https://docs.abs.xyz/)
- [Official Site](https://abs.xyz/)
- [GitHub](https://github.com/Abstract-Foundation)
- [X](https://x.com/AbstractChain)
- [Discord](https://discord.com/invite/abstractchain)
11 changes: 11 additions & 0 deletions session-keys-subscription-payments/contracts/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[profile.default]
src = 'src'
libs = ['lib']
fallback_oz = true

[profile.default.zksync]
enable_eravm_extensions = true # Note: System contract calls (NonceHolder and ContractDeployer) can only be called with this set to true

[etherscan]
abstractTestnet = { chain = "11124", url = "", key = ""} # You can replace these values or leave them blank to override via CLI
abstractMainnet = { chain = "2741", url = "", key = ""} # You can replace these values or leave them blank to override via CLI
1 change: 1 addition & 0 deletions session-keys-subscription-payments/contracts/lib/forge-std
Submodule forge-std added at 77041d
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/**
* @title SubscriptionService
* @dev Minimal contract for subscription management
*/
contract SubscriptionService {
uint256 public constant subscriptionFee = 0.0001 ether;
uint256 public constant subscriptionDuration = 15 minutes;

mapping(address => uint256) public subscriptionExpiry;

event NewSubscription(address indexed subscriber, uint256 expiresAt);

/**
* @dev Subscribe to the service
*/
function subscribe() external payable {
require(msg.value == subscriptionFee, "Incorrect payment amount");

subscriptionExpiry[msg.sender] = block.timestamp + subscriptionDuration;

emit NewSubscription(msg.sender, subscriptionExpiry[msg.sender]);
}

/**
* @dev Check if an address has an active subscription
*/
function isSubscribed(address user) external view returns (bool) {
return subscriptionExpiry[user] > block.timestamp;
}
}
16 changes: 16 additions & 0 deletions session-keys-subscription-payments/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
});

const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
];

export default eslintConfig;
7 changes: 7 additions & 0 deletions session-keys-subscription-payments/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
};

export default nextConfig;
34 changes: 34 additions & 0 deletions session-keys-subscription-payments/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "agw-nextjs",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@abstract-foundation/agw-client": "latest",
"@abstract-foundation/agw-react": "latest",
"@privy-io/cross-app-connect": "^0.2.1",
"@tanstack/react-query": "^5.71.5",
"next": "15.2.4",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"viem": "^2.25.0",
"wagmi": "^2.14.16"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.2.4",
"tailwindcss": "^4",
"typescript": "^5"
},
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"
}
Loading