zkLogin is a Sui primitive that allows users to transact on Sui using the OAuth login flows they’re familiar with, eliminating the friction of handling cryptographic keys or remembering mnemonics. zkLogin can be thought of as a two-factor authentication scheme, since sending a transaction requires both a credential from a recent OAuth login and a salt managed by someone other than the OAuth provider (in this case, Shinami). To learn more, see the Sui Foundation’s zkLogin doc..You’ll find API endpoints and key usage notes below. If you ever need help you can reach out to us.
AuthenticationYou authenticate via an access key passed in a header (‘X-Api-Key: ACCESS_KEY’) or in the request url, e.g. https://api.us1.shinami.com/sui/zkprover/v1/ACCESS_KEY. We recommend using a request header and not putting access keys in your request URLs for reduced visibility (in logs, etc). These steps are done automatically by our TypeScript SDK. Region URLs - us1 above - only work with API keys created in the same region. So, to use this API, you’ll make Wallet Services API keys in our US East - us1 region.For more information, including how to set up an access key with Wallet Services rights, see our Authentication and API Keys guide.
Call this API from your backendShinami Wallet Services do not support CORS requests, so if you call these APIs from your frontend you’ll get a CORS error. This is for security reasons: exposed wallet information could lead to malicious actors signing transactions on behalf of your users.
Error HandlingSee our Error Reference for guidance on the errors you may receive from our services, including a section on errors specific to the zkLogin wallet API.Rate LimitsWhen you surpass the QPS limit for a key, we return a JSON-RPC error code -32010. We recommend implementing retries with a backoff to handle any rate limits errors that arise. You can also adjust the rate limits of your keys to better balance your QPS allotment across your keys.We also have a limit of two zk proofs per address per minute. When you hit this limit, we return a JSON-RPC code -32012.
A zkLogin wallet address is derived from iss, aud, sub, salt in the OpenID connect response, where:
iss: The OpenID provider.
aud : The unique identifier assigned to your application by the OpenID provider.
sub: The OpenID provider’s locally unique and never reassigned identifier for the user.
salt: A consistent, ideally unique, value used to unlink the OpenID identifier with the on-chain address.
As a result, a user will have a new zkLogin wallet address if any of the above values change. For example, if one of your users logs in via Google and then Twitch - or with one Google email and then another - and you use both credentials with zkLogin, each credential will be linked to a different address. To learn more, see the Sui Foundation’s zkLogin doc.
The endpoints below show sample requests using our TypeScript SDK (in addition to cURL).We also have a Next.js zkLogin SDK, which aims to provide full-stack support for building user authentication and Sui transaction execution into your Next.js application, using zkLogin primitives. We built a Next.js starter template to quickly get you off the ground using this SDK. Even if you are starting with an existing Next.js application, it’s recommended to check out that example as a reference end-to-end implementation. Our Next.js tutorial has guidance on running our zkLogin app starter template.
Retrieves a zkLogin wallet along with its associated salt, creating a new wallet if necessary. This method provides the option to create and use multiple zkLogin wallets per (user, OAuth provider) pair by using the optional subWallet parameter. Note that your users will already have a different zkLogin wallet for each OAuth provider they use, whose jwt you pass to this method (see zkLogin Addresses for more details).On the free tier you have a limit of wallet creations per month as shown on the “Sui Wallet Services” tab of the billing page in your dashboard (where you can also see how to upgrade if needed). If you hit this limit, you will get a JSON-RPC code -32012 and should not retry. All other wallet operations will still work for the month, like signing with wallets you’ve already created.Request Parameters
Name
Type
Description
jwt
String
A valid JWT signed by one of the supported OpenID providers. The JWT nonce must be prepared according to the zkLogin requirements .
keyClaimName
String
Optional. The claim name in the JWT that identifies a particular user. Defaults to “sub”. Currently, Mysten’s zkLogin implementation only supports the “sub” field of the OpenID spec. This parameter allows for forward compatibility as the implementation expands to support other values.
subWallet
Integer
Optional. The sub-wallet id, which enables the same OpenID user to have more than one wallet address tied to your app. Defaults to 0
Example Request TemplateThe TypeScript example uses the Shinami Clients SDK, which you can install with:
Copy
Ask AI
npm install @shinami/clients
Replace all instances of {{name}} with the actual value for that name.
Generate a zkLogin proof prior to signing and executing a transaction. The example below uses the Shinami Clients SDK.Notes:
Devnet has a different zkey than Testnet and Mainnet. Shinami’s zk prover currently only works with Testnet and Mainnet.
We have a limit of two zk proofs per address per minute. When you hit this limit, we return a JSON-RPC code -32012.
Request Parameters
Name
Type
Description
jwt
string
A valid JWT signed by one of the supported OpenID providers. The JWT nonce must be prepared according to the zkLogin requirements.
maxEpoch
cURL: stringSDK: number
The max epoch used to prepare the JWT nonce. This governs the expiration of the zkLogin proof. Once it expires, you will have to ask the user to sign in again. One epoch is roughly one day. See the expiration of recent epochs in a Sui explorer like Suivision or Suiscan (note that Mainnet and Testnet are not on the same epoch).
extendedEphemeralPublicKey
cURL: BigInt representation or Base64 encodedSDK: PublicKey
The extended ephemeral public key used to prepare the JWT nonce (see example of how to generate it here). The corresponding private key must be used to sign any transactions to be executed with this proof.
jwtRandomness
cURL: string: BigInt representation or Base64 encoded SDK: bigint
The random bytes used to prepare the JWT nonce (see example here).
salt
cURL: string: BigInt representation or Base64 encoded SDK: bigint
The zkLogin wallet salt. Together with the provided JWT, this determines the zkLogin wallet’s on-chain address. This method works with salts managed by Shinami, buy you, by another third party, or by the user. Note, though, that if the salt changes, the user’s address changes.
keyClaimName
string
Optional. The claim name in the JWT that identifies a particular user. Defaults to “sub”. Currently, Mysten’s zkLogin implementation only supports the sub field of the OpenID spec. This parameter allows for forward compatibility as the implementation expands to support other values.
Example Request TemplateThe TypeScript example uses the Shinami Clients SDK, which you can install with:
Copy
Ask AI
npm install @shinami/clients
Replace all instances of {{name}} with the actual value for that name.
JSON RPC -32002 on transaction execution (Invalid user signature)
Example error
Copy
Ask AI
JsonRpcError: Invalid user signature: Required Signature from 0x6e20e4e7e3822ccd19614dd8db4fafdab3e0a888d54d272ef678a4c24937c5b4 is absent ["0x1c1a56df0bd80abc6dd097b98cd4ff341c3ef2bdb0f2ea7d0ebd87eff3268b6c", "0x3452ddf0448cc52e62d263c1c49553cb744dbb76bca56e9f12c98b2ffb9b82a5"] at SuiHTTPTransport.request (...node_modules/@mysten/sui/src/client/http-transport.ts:123:10) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at SuiClient.executeTransactionBlock (...src/server/main.ts:135:30) { code: -32002, type: 'TransactionExecutionClientError'}
Possible cause: passing incorrect or missing values when generating address seed and zk signatureEnsure that you’re providing all the correct values when generating your emphemeral Keypair signature, address seed, and zkLogin signature (all the steps in this section).The above error happened for me because I wasn’t properly storing the sub value, and I was retrieving it as undefined from session storage when generating my address seed. Once I printed out my key variable values (sub, aud, salt, maxEpoch, ephemeral Keypair public key or address) at the time of fetching the JWT and compared them to the what I fetched from session storage right before generating my address seed and zkLogin signature, I was able to catch and fix the issue. Then my transaction when through without an error.