grantDelegation
Grant a delegated signer access to one or more selectors until an expiry timestamp.
import { grantDelegation } from "@symmio/trading-core";
const hash = await grantDelegation(config, {
account: { addr: account, isPartyB: false },
delegatedSigner: delegate,
selectors: ["0x501e891f"],
expiryTimestamp: 1_766_000_000n,
});Parameters
Account that grants the delegation. The connected wallet must own this account.
delegatedSignerAddressrequiredSigner that may call the selected Instant Layer functions.
selectorsreadonly Hex[]requiredFunction selectors (bytes4[]) to grant. For the instant-trade lifecycle, resolve the chain’s set with
getInstantTradeRequiredSelectors(config, {chainId}) — the open-leg selector is per-chain (sendQuote on a
perps-core v0.8.6 chain, the legacy sendQuoteWithAffiliateAndData on v0.8.5). The static sets
(INSTANT_TRADE_REQUIRED_SELECTORS / LEGACY_INSTANT_TRADE_REQUIRED_SELECTORS) are exported for single-chain
flows.
expiryTimestampbigintrequiredExpiry timestamp in seconds.
chainIdnumberoptionalOptional chain override.
simulateBeforeWritebooleanoptionalDry-run via simulateContract first (defaults to the config’s setting, itself true by default). Ignored on the
relayed path — there is no transaction to dry-run, and the relayer simulates its own bundle.
gaslessboolean | GaslessWriteOptionsoptionalRelay the grant instead of sending a transaction. Omitted, the chain’s gasless.execution.mode decides. See
relayable writes.
Returns
HashThe submitted transaction hash. A relayed grant returns the relayer’s broadcast hash, which behaves exactly like a
wallet-submitted one — so the transport never leaks into the type. Dry-run without sending via
simulateGrantDelegation(config, params).
This grant costs no native gas under gasless execution. The grant is itself a relayable write, so
a wallet with an empty balance can still onboard a session key. Pass
GASLESS_SESSION_KEY_SELECTORS as selectors — never
GASLESS_RELAYABLE_SELECTORS, which includes grantDelegation itself and would let the key re-delegate.
A isPartyB: true account cannot be relayed — the signed-operation encoder has no PartyB form. Such a grant takes the
wallet path, and throws GASLESS_PARTYB_UNSUPPORTED if gasless was demanded explicitly with gasless: true.