What is the best approach to handle gas fees during zk login for submitting a transaction to obtain an ephemeral signature?

For example:
final ephemeralSign = await txb.sign(SignOptions(signer: ephemeralKeypair, client: client));

To obtain ephemeralSign, the user needs to sign the transaction. However, for onboarding new users who are not familiar with web3, it is often necessary to manage the gas fees at the product level.

What is the recommended approach for handling gas fees during zk login implementation? Should we use sponsored transactions or is there a better alternative?

1 Like

I believe I’ve found my answer, i was slightly confused. Creating a fresh account via zk login is straightforward, as it can be decoded from the JWT:

for eg: var address = jwtToAddress(idToken, BigInt.parse(userSalt));

When a user wants to submit a transaction, they first generate a partialZkLoginSignature, followed by a complete zkLoginSignature. To execute the transaction, they need gas to top up their freshly created account, which applies to both zkLogin and any other account type.

const { bytes, signature: userSignature } = await txb.sign({
  client,
  signer: ephemeralKeyPair
});


const addressSeed: string = genAddressSeed(
  BigInt(userSalt),
  "sub",
  decodedJwt.sub,
  decodedJwt.aud
).toString();


const zkLoginSignature: SerializedSignature = getZkLoginSignature({
  inputs: {
    ...partialZkLoginSignature,
    addressSeed,
  },
  maxEpoch,
  userSignature,
});

Thanks team.

1 Like