Skip to main content

Calibur Utility Methods

Lower-level Calibur7702Account helpers. Most integrations do not need them: createUserOperation fetches the nonce and encodes the call data for you. To create the account from an existing EOA and send UserOperations, start with Calibur Account.

Methods at a Glance​

MethodSignatureReturns
getNoncegetNonce(providerRpc, sequenceKey?)Promise<bigint>
createAccountCallData (static)Calibur7702Account.createAccountCallData(transactions, revertOnFailure?)string
wrapSignature (static)Calibur7702Account.wrapSignature(keyHash, rawSignature, hookData?)string
getUserOperationHashgetUserOperationHash(userOperation, chainId)string
prependTokenPaymasterApproveToCallDataprependTokenPaymasterApproveToCallData(callData, tokenAddress, paymasterAddress, approveAmount)string
prependTokenPaymasterApproveToCallDataStatic (static)Calibur7702Account.prependTokenPaymasterApproveToCallDataStatic(callData, tokenAddress, paymasterAddress, approveAmount)string
createInvalidateNonceMetaTransaction (static)Calibur7702Account.createInvalidateNonceMetaTransaction(newNonce)SimpleMetaTransaction

Utility Methods​

getNonce​

Gets the account nonce from the EntryPoint. Supports parallel nonce channels via the optional sequenceKey parameter.

example.ts
// Default nonce (sequence key = 0)
const nonce = await smartAccount.getNonce(
"https://ethereum-sepolia-rpc.publicnode.com"
);
console.log("Nonce:", nonce);

// Parallel nonce channel
const parallelNonce = await smartAccount.getNonce(
"https://ethereum-sepolia-rpc.publicnode.com",
1 // sequence key
);

Source code​

getNonce

createAccountCallData​

Static method. Encodes calldata for executeUserOp with BatchedCall format. All transactions (even single ones) go through the same BatchedCall path.

example.ts
import { Calibur7702Account } from "abstractionkit";

const transactions = [
{ to: "0x...", value: 0n, data: "0x..." },
{ to: "0x...", value: 1000000000000000000n, data: "0x" },
];

const callData = Calibur7702Account.createAccountCallData(transactions);

// With revertOnFailure disabled (individual calls can fail without reverting the batch)
const callDataNoRevert = Calibur7702Account.createAccountCallData(transactions, false);

Source code​

createAccountCallData

wrapSignature​

Static method. Wraps a raw ECDSA signature in Calibur's signature format: abi.encode(bytes32 keyHash, bytes signature, bytes hookData). Use this when signing externally (e.g., with viem, hardware wallet, MPC) to avoid manually ABI-encoding the wrapped signature.

example.ts
import { Calibur7702Account } from "abstractionkit";

// Root key hash (bytes32 zero) for the EOA's own key
const ROOT_KEY_HASH = "0x0000000000000000000000000000000000000000000000000000000000000000";

const rawEcdsaSignature = "0x..."; // 65-byte ECDSA signature

// Wrap for root key
const wrappedSignature = Calibur7702Account.wrapSignature(
ROOT_KEY_HASH,
rawEcdsaSignature,
);

// Wrap for a secondary key with hook data
const wrappedWithHook = Calibur7702Account.wrapSignature(
"0x...secondary-key-hash",
rawEcdsaSignature,
"0x...hook-data",
);

Source code​

wrapSignature

getUserOperationHash​

Computes the UserOperation hash for this account's EntryPoint. Convenience wrapper that automatically uses this account's EntryPoint address.

example.ts
const userOpHash = smartAccount.getUserOperationHash(
userOperation,
11155111n // chain ID
);

console.log("UserOperation hash:", userOpHash);
// Use this hash as the challenge for WebAuthn assertions

Source code​

getUserOperationHash

prependTokenPaymasterApproveToCallData​

Prepends a token approve call to existing calldata for a token paymaster. Decodes the existing BatchedCall, prepends an ERC-20 approve transaction, and re-encodes.

example.ts
const callDataWithApproval = smartAccount.prependTokenPaymasterApproveToCallData(
userOperation.callData,
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC token address (Ethereum mainnet)
"0x...", // paymaster address
1000000n // approve amount (1 USDC)
);

userOperation.callData = callDataWithApproval;

Source code​

prependTokenPaymasterApproveToCallData

createInvalidateNonceMetaTransaction​

Static method. Creates a meta-transaction that invalidates Calibur nonces up to a given value. newNonce is laid out as (key << 64) | sequence, and every nonce of that key below the sequence becomes invalid. This acts on Calibur's own nonce, the one its signed batched calls use. It does not change the EntryPoint nonce that getNonce reads and UserOperations use, so it cannot cancel a signed UserOperation.

example.ts
import { Calibur7702Account } from "abstractionkit";

// Invalidate Calibur nonces of key 0 below sequence 100
const invalidateTx = Calibur7702Account.createInvalidateNonceMetaTransaction(100n);

const userOperation = await smartAccount.createUserOperation(
[invalidateTx],
nodeRpc,
bundlerRpc,
);

Source code​

createInvalidateNonceMetaTransaction