bcnmy / bcnmy/abstractjs

[GENERAL] Failed to consume permission when integrating Smart Sessions module.

Open
#173 1 comment 0 reactions 0 assignees View on GitHub
enhancement question
Dominant language
TypeScript
Stars
8
Forks
12
Avg merge
2h 15m
Merged PRs (30d)
1

Description

### Inquiry or Suggestion

### ❓ Summary

I’m integrating Smart Sessions with AbstractJS and ran into an error when consuming permissions.
Ref: https://docs.biconomy.io/new/smart-sessions/execute-transactions-on-users-behalf

### 🧪 Environment

- abstractjs version: 1.1.18
- Node.js version: v20.3.1
- Network: Base

### 🧩 Steps to Reproduce

1. Deployed Smart Account
2. Installed Sessions Module
3. Defined & granted permissions via grantPermissionTypedDataSign
4. Tried to consume permission with usePermission

### 🛠 Code

```ts
const incrementCount = async () => {
if (!sessionDetails || !sessionSigner || !orchestrator) return;

console.log("sessionDetails", sessionDetails);

const toastId = toast("Executing transaction with session...", {
autoClose: false,
});

try {
const orchestratorAddress = orchestrator.addressOn(base.id)!;
const userOwnedOrchestratorWithSessionSigner =
await toMultichainNexusAccount({
chainConfigurations: [
{
chain: base,
transport: http(),
version: getMEEVersion(MEEVersion.V2_1_0),
accountAddress: orchestratorAddress,
},
],
signer: sessionSigner,
});

const sessionApiKey = process.env.NEXT_PUBLIC_BICONOMY_API_KEY || getDefaultMEENetworkApiKey(false);
const sessionMeeUrl = getDefaultMEENetworkUrl(false);
console.log("=== Session Signer MEE Client ===");
console.log("API Key:", sessionApiKey ? `${sessionApiKey.substring(0, 15)}...` : "undefined");
console.log("MEE URL:", sessionMeeUrl);

if (!sessionApiKey) {
throw new Error("API key is required for session signer MEE client");
}

const sessionSignerMeeClient = await createMeeClient({
account: userOwnedOrchestratorWithSessionSigner,
apiKey: sessionApiKey,
url: sessionMeeUrl,
});

const sessionSignerSessionMeeClient =
sessionSignerMeeClient.extend(meeSessionActions);

const incrementAbiItem = getAbiItem({ abi: contractABI, name: "increment" });
if (!incrementAbiItem || incrementAbiItem.type !== "function") {
throw new Error("Could not find increment function in ABI");
}
const incrementSelector = toFunctionSelector(incrementAbiItem);

console.log("About to use permission to execute transaction");
const serializeBigInt = (obj: any): any => {
if (obj === null || obj === undefined) return obj;
if (typeof obj === 'bigint') {
return obj.toString();
}
if (Array.isArray(obj)) {
return obj.map(serializeBigInt);
}
if (typeof obj === 'object') {
const serialized: any = {};
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
serialized[key] = serializeBigInt(obj[key]);
}
}
return serialized;
}
return obj;
};
console.log("Session Details:", JSON.stringify(serializeBigInt(sessionDetails), null, 2));
console.log("Contract Address:", CONTRACT_ADDRESS);
console.log("Increment Selector:", incrementSelector);

const executionPayload = await sessionSignerSessionMeeClient.usePermission({
sessionDetails,
mode: "ENABLE_AND_USE",
instructions: [
{
chainId: base.id, // Base chainId = 8453
calls: [
{
to: CONTRACT_ADDRESS,
data: incrementSelector,
},
],
},
],
feeToken: {
address: "0x0000000000000000000000000000000000000000" as `0x${string}`,
chainId: base.id,
},
// verificationGasLimit: BigInt(500000000000000), // Increase verification gas
});

console.log("Execution payload:", executionPayload);

console.log("Waiting for execution receipt, hash:", executionPayload.hash);
const receipt = await sessionSignerMeeClient.waitForSupertransactionReceipt({
hash: executionPayload.hash,
mode: "fast-block",
confirmations: 1,
waitForReceipts: true,
});
console.log("Execution receipt received:", receipt);

setTxnHash(executionPayload.hash);

toast.update(toastId, {
render: "Transaction executed successfully!",
type: "success",
autoClose: 5000,
});
} catch (err: any) {
toast.update(toastId, {
render: `Error: ${err.message}`,
type: "error",
autoClose: 5000,
});
console.error(err);
}
};
```

### 🔥 Error

```
POST https://network.biconomy.io/v1/exec 400 (Bad Request)
VM217 index.tsx:551 Error: FailedOpWithRevert: AA23 reverted
at async incrementCount (VM217 index.tsx:510:38)
```

### ❗ What I Expected

Permission to be consumed and transaction to execute successfully.

### 🚀 Any suggestions?

### Relevant Links or References

https://docs.biconomy.io/new/smart-sessions/execute-transactions-on-users-behalf

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the usePermission call in the provided incrementCount flow and compare its sessionDetails, ENABLE_AND_USE mode, instructions, and feeToken with the linked Smart Sessions documentation. Inspect the resulting AA23 revert and related AbstractJS permission-consumption path; done means the permission is consumed and the transaction executes successfully on Base.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.