getGaslessBatchSelectors
Build the selector set a session key must hold to relay a gasless batch — each relayable write’s selector, plus the wallet-execution sentinel and every inner call’s selector for each GaslessWallet entry.
import { getGaslessBatchSelectors, grantDelegation, relayGaslessBatch } from "@symmio/trading-core";
const calls = [
{ functionName: "allocate", args: [amount] },
{ walletCalls: [{ target: usdc, abi: erc20Abi, functionName: "transfer", args: [to, value] }] },
];
await grantDelegation(config, {
account: { addr: subAccount, isPartyB: false },
delegatedSigner: sessionKey,
selectors: getGaslessBatchSelectors(calls),
expiryTimestamp,
});
await relayGaslessBatch(config, { account: subAccount, calls, from: sessionKey });Grant the set on the batch’s account: both execution paths check delegated permissions on the canonical account, which is a live virtual account’s parent. The result is lowercased and de-duplicated in first-seen order.
For a mixed-signer batch, pass only the calls that the particular delegate signs. This helper collects selectors from every supplied call; it does not resolve from or group permissions by signer. For example, keep sessionCalls separate when building the batch, derive getGaslessBatchSelectors(sessionCalls), then include those calls with from: sessionKey after the owner’s grant.
Selectors come from the encoded calldata, so an overloaded ABI resolves to the function that will actually run — and a named call is encoded against the SDK’s own ABI for the relayable write of that name.
Each grantDelegation or grantDelegations entry must be owner-signed: the InstantLayer rejects a delegate-signed
grant. Other entries can use their own signers. A key granted transfer can send the wallet’s whole balance to any
recipient, because delegations bind selectors, not arguments. Grant the narrowest batch you can.
Parameters
callsreadonly GaslessBatchCall[]requiredThe calls signed by this delegate, in any order and any of the call forms.
Returns
readonly Hex[]bytes4 hex.Throws
SymmError("validation", "GASLESS_NOT_RELAYABLE")when a call without anabinames no relayable write.- Viem’s encoding error when an ABI-level call’s arguments do not encode.