Skip to content

Commit 53ad188

Browse files
committed
[Portal] EIP-7702 Session Key Docs (.NET)
1 parent 9e56d05 commit 53ad188

File tree

6 files changed

+379
-0
lines changed

6 files changed

+379
-0
lines changed

apps/portal/src/app/dotnet/sidebar.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,26 @@ const walletActions: SidebarLink = (() => {
108108
href: `${parentSlug}/createsessionkey7702`,
109109
name: "CreateSessionKey (EIP-7702)",
110110
},
111+
{
112+
href: `${parentSlug}/signerhaspermissions7702`,
113+
name: "SignerHasFullPermissions",
114+
},
115+
{
116+
href: `${parentSlug}/getcallpolicies7702`,
117+
name: "GetCallPoliciesForSigner",
118+
},
119+
{
120+
href: `${parentSlug}/gettransferpolicies7702`,
121+
name: "GetTransferPoliciesForSigner",
122+
},
123+
{
124+
href: `${parentSlug}/getsessionexpiration7702`,
125+
name: "GetSessionExpirationForSigner",
126+
},
127+
{
128+
href: `${parentSlug}/getsessionstate7702`,
129+
name: "GetSessionStateForSigner",
130+
},
111131
],
112132
name: "InAppWallet & EcosystemWallet",
113133
},
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { Details, createMetadata } from "@doc";
2+
3+
export const metadata = createMetadata({
4+
title: "EcosystemWallet.GetCallPoliciesForSigner | Thirdweb .NET SDK",
5+
description:
6+
"Gets the call policies for a specific signer on the EIP-7702 account.",
7+
});
8+
9+
# EcosystemWallet.GetCallPoliciesForSigner
10+
11+
Gets the call policies for a specific signer on the EIP-7702 account. Returns a list of `CallSpec` objects that define which contracts and functions the signer can call.
12+
13+
## Usage
14+
15+
```csharp
16+
// Get call policies for a signer
17+
var callPolicies = await ecosystemWallet.GetCallPoliciesForSigner(
18+
chainId: 1,
19+
signerAddress: "0x1234567890123456789012345678901234567890"
20+
);
21+
22+
// Examine the policies
23+
foreach (var policy in callPolicies)
24+
{
25+
Console.WriteLine($"Can call {policy.Target} with selector {BitConverter.ToString(policy.Selector)}");
26+
Console.WriteLine($"Max value per use: {policy.MaxValuePerUse}");
27+
Console.WriteLine($"Constraints: {policy.Constraints.Count}");
28+
}
29+
```
30+
31+
<Details summary="Parameters">
32+
33+
### chainId
34+
35+
`BigInteger`: The chain ID of the EIP-7702 account.
36+
37+
### signerAddress
38+
39+
`string`: The address of the signer to get call policies for.
40+
41+
</Details>
42+
43+
<Details summary="Return Value">
44+
45+
### List&lt;CallSpec&gt;
46+
47+
A list of call policies for the signer. Each `CallSpec` contains:
48+
- `Target`: Contract address that can be called
49+
- `Selector`: Function selector (4 bytes) that can be called
50+
- `MaxValuePerUse`: Maximum ETH value per function call
51+
- `ValueLimit`: Overall spending limits
52+
- `Constraints`: Parameter constraints for function calls
53+
54+
</Details>
55+
56+
<Details summary="Exceptions">
57+
58+
### InvalidOperationException
59+
60+
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
61+
62+
### ArgumentException
63+
64+
Thrown when the signer address is null or empty.
65+
66+
</Details>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { Details, createMetadata } from "@doc";
2+
3+
export const metadata = createMetadata({
4+
title: "EcosystemWallet.GetSessionExpirationForSigner | Thirdweb .NET SDK",
5+
description:
6+
"Gets the session expiration timestamp for a specific signer on the EIP-7702 account.",
7+
});
8+
9+
# EcosystemWallet.GetSessionExpirationForSigner
10+
11+
Gets the session expiration timestamp for a specific signer on the EIP-7702 account. Returns the Unix timestamp when the session key expires.
12+
13+
## Usage
14+
15+
```csharp
16+
// Get session expiration for a signer
17+
var expirationTimestamp = await ecosystemWallet.GetSessionExpirationForSigner(
18+
chainId: 1,
19+
signerAddress: "0x1234567890123456789012345678901234567890"
20+
);
21+
22+
// Convert to DateTime for readability
23+
var expirationDateTime = DateTimeOffset.FromUnixTimeSeconds((long)expirationTimestamp);
24+
Console.WriteLine($"Session expires at: {expirationDateTime}");
25+
26+
// Check if session is still valid
27+
var currentTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
28+
bool isValid = expirationTimestamp > currentTime;
29+
Console.WriteLine($"Session is valid: {isValid}");
30+
31+
if (isValid)
32+
{
33+
var timeRemaining = expirationDateTime - DateTimeOffset.UtcNow;
34+
Console.WriteLine($"Time remaining: {timeRemaining.TotalHours:F1} hours");
35+
}
36+
```
37+
38+
<Details summary="Parameters">
39+
40+
### chainId
41+
42+
`BigInteger`: The chain ID of the EIP-7702 account.
43+
44+
### signerAddress
45+
46+
`string`: The address of the signer to get session expiration for.
47+
48+
</Details>
49+
50+
<Details summary="Return Value">
51+
52+
### BigInteger
53+
54+
The Unix timestamp when the session expires. Use `DateTimeOffset.FromUnixTimeSeconds()` to convert to a readable date.
55+
56+
</Details>
57+
58+
<Details summary="Exceptions">
59+
60+
### InvalidOperationException
61+
62+
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
63+
64+
### ArgumentException
65+
66+
Thrown when the signer address is null or empty.
67+
68+
</Details>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { Details, createMetadata } from "@doc";
2+
3+
export const metadata = createMetadata({
4+
title: "EcosystemWallet.GetSessionStateForSigner | Thirdweb .NET SDK",
5+
description:
6+
"Gets the complete session state for a specific signer on the EIP-7702 account, including remaining limits and usage information.",
7+
});
8+
9+
# EcosystemWallet.GetSessionStateForSigner
10+
11+
Gets the complete session state for a specific signer on the EIP-7702 account, including remaining limits and usage information. This provides a comprehensive view of what the signer can still do within their session limits.
12+
13+
## Usage
14+
15+
```csharp
16+
// Get complete session state for a signer
17+
var sessionState = await ecosystemWallet.GetSessionStateForSigner(
18+
chainId: 1,
19+
signerAddress: "0x1234567890123456789012345678901234567890"
20+
);
21+
22+
// Check remaining transfer limits
23+
Console.WriteLine("Transfer Limits:");
24+
foreach (var limit in sessionState.TransferValue)
25+
{
26+
string tokenType = limit.Target == "0x0000000000000000000000000000000000000000"
27+
? "ETH"
28+
: $"Token {limit.Target}";
29+
Console.WriteLine($" {tokenType}: {limit.Remaining} remaining");
30+
}
31+
32+
// Check remaining call value limits
33+
Console.WriteLine("\nCall Value Limits:");
34+
foreach (var limit in sessionState.CallValue)
35+
{
36+
Console.WriteLine($" {limit.Target}.{BitConverter.ToString(limit.Selector)}: {limit.Remaining} ETH remaining");
37+
}
38+
39+
// Check parameter constraint limits
40+
Console.WriteLine("\nParameter Constraints:");
41+
foreach (var limit in sessionState.CallParams)
42+
{
43+
Console.WriteLine($" {limit.Target}.{BitConverter.ToString(limit.Selector)} param[{limit.Index}]: {limit.Remaining} remaining");
44+
}
45+
```
46+
47+
<Details summary="Parameters">
48+
49+
### chainId
50+
51+
`BigInteger`: The chain ID of the EIP-7702 account.
52+
53+
### signerAddress
54+
55+
`string`: The address of the signer to get session state for.
56+
57+
</Details>
58+
59+
<Details summary="Return Value">
60+
61+
### SessionState
62+
63+
An object containing the current session state with three arrays:
64+
65+
#### TransferValue
66+
- `LimitState[]`: Remaining limits for token transfers
67+
- Each entry shows remaining transfer amounts for specific tokens
68+
69+
#### CallValue
70+
- `LimitState[]`: Remaining ETH value limits for contract calls
71+
- Each entry shows remaining ETH that can be sent with function calls
72+
73+
#### CallParams
74+
- `LimitState[]`: Remaining limits for constrained function parameters
75+
- Each entry shows remaining usage for specific parameter constraints
76+
77+
#### LimitState Properties
78+
- `Remaining`: Amount remaining for this limit
79+
- `Target`: Contract or token address
80+
- `Selector`: Function selector (for calls only)
81+
- `Index`: Parameter index (for parameter constraints only)
82+
83+
</Details>
84+
85+
<Details summary="Exceptions">
86+
87+
### InvalidOperationException
88+
89+
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
90+
91+
### ArgumentException
92+
93+
Thrown when the signer address is null or empty.
94+
95+
</Details>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { Details, createMetadata } from "@doc";
2+
3+
export const metadata = createMetadata({
4+
title: "EcosystemWallet.GetTransferPoliciesForSigner | Thirdweb .NET SDK",
5+
description:
6+
"Gets the transfer policies for a specific signer on the EIP-7702 account.",
7+
});
8+
9+
# EcosystemWallet.GetTransferPoliciesForSigner
10+
11+
Gets the transfer policies for a specific signer on the EIP-7702 account. Returns a list of `TransferSpec` objects that define which tokens the signer can transfer and with what limits.
12+
13+
## Usage
14+
15+
```csharp
16+
// Get transfer policies for a signer
17+
var transferPolicies = await ecosystemWallet.GetTransferPoliciesForSigner(
18+
chainId: 1,
19+
signerAddress: "0x1234567890123456789012345678901234567890"
20+
);
21+
22+
// Examine the policies
23+
foreach (var policy in transferPolicies)
24+
{
25+
string tokenType = policy.Target == "0x0000000000000000000000000000000000000000"
26+
? "ETH"
27+
: $"Token {policy.Target}";
28+
29+
Console.WriteLine($"Can transfer {tokenType}");
30+
Console.WriteLine($"Max per transfer: {policy.MaxValuePerUse}");
31+
Console.WriteLine($"Limit type: {policy.ValueLimit.LimitType}");
32+
}
33+
```
34+
35+
<Details summary="Parameters">
36+
37+
### chainId
38+
39+
`BigInteger`: The chain ID of the EIP-7702 account.
40+
41+
### signerAddress
42+
43+
`string`: The address of the signer to get transfer policies for.
44+
45+
</Details>
46+
47+
<Details summary="Return Value">
48+
49+
### List&lt;TransferSpec&gt;
50+
51+
A list of transfer policies for the signer. Each `TransferSpec` contains:
52+
- `Target`: Token contract address (`0x0000000000000000000000000000000000000000` for ETH)
53+
- `MaxValuePerUse`: Maximum amount per transfer transaction
54+
- `ValueLimit`: Overall usage limits with type and period
55+
56+
</Details>
57+
58+
<Details summary="Exceptions">
59+
60+
### InvalidOperationException
61+
62+
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
63+
64+
### ArgumentException
65+
66+
Thrown when the signer address is null or empty.
67+
68+
</Details>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { Details, createMetadata } from "@doc";
2+
3+
export const metadata = createMetadata({
4+
title: "EcosystemWallet.SignerHasFullPermissions | Thirdweb .NET SDK",
5+
description:
6+
"Checks if a signer has full permissions (wildcard access) on the EIP-7702 account.",
7+
});
8+
9+
# EcosystemWallet.SignerHasFullPermissions
10+
11+
Checks if the signer has full permissions on the EIP-7702 account. Returns `true` if the signer is a wildcard signer with unrestricted access.
12+
13+
## Usage
14+
15+
```csharp
16+
// Check if a signer has full permissions
17+
bool hasFullPermissions = await ecosystemWallet.SignerHasFullPermissions(
18+
chainId: 1,
19+
signerAddress: "0x1234567890123456789012345678901234567890"
20+
);
21+
22+
if (hasFullPermissions)
23+
{
24+
Console.WriteLine("Signer has unlimited access to the wallet");
25+
}
26+
else
27+
{
28+
Console.WriteLine("Signer has restricted access based on policies");
29+
}
30+
```
31+
32+
<Details summary="Parameters">
33+
34+
### chainId
35+
36+
`BigInteger`: The chain ID of the EIP-7702 account.
37+
38+
### signerAddress
39+
40+
`string`: The address of the signer to check permissions for.
41+
42+
</Details>
43+
44+
<Details summary="Return Value">
45+
46+
### bool
47+
48+
`true` if the signer has full permissions (wildcard access), `false` if the signer has restricted permissions or no permissions.
49+
50+
</Details>
51+
52+
<Details summary="Exceptions">
53+
54+
### InvalidOperationException
55+
56+
Thrown when the execution mode is not EIP7702 or EIP7702Sponsored.
57+
58+
### ArgumentException
59+
60+
Thrown when the signer address is null or empty.
61+
62+
</Details>

0 commit comments

Comments
 (0)