zksync-sso 0.4.0-beta.2
Install from the command line:
Learn more about npm packages
$ npm install @matter-labs/zksync-sso@0.4.0-beta.2
Install via package.json:
"@matter-labs/zksync-sso": "0.4.0-beta.2"
About this version
A user & developer friendly modular smart account implementation on ZKsync; simplifying user authentication, session management, and transaction processing.
ZKsync SSO is under active development and is not yet feature complete. Use it to improve your development applications and tooling. Please do not use it in production environments.
- π§© Modular smart accounts based on ERC-7579
- π Passkey authentication (no seed phrases)
- β° Sessions with easy configuration and management
- π° Integrated paymaster support
- β€οΈβπ©Ή Account recovery
- π» Simple SDKs : JavaScript, iOS/Android (Coming Soon)
- π€ Open-source authentication server
- π Examples to get started quickly
Install the ZKsync SSO SDK package:
npm i zksync-sso
# optional peer dependencies
npm i @simplewebauthn/browser @simplewebauthn/server @wagmi/core
Optional peer dependencies that you may need to install based on your usage:
-
@simplewebauthn/browser
and@simplewebauthn/server
(v13.x) - Required for passkey operations -
@wagmi/core
(v2.x) - Required for using the SSO connector
Add ZKsync SSO connector to your app (using wagmi
):
import { zksyncSsoConnector, callPolicy } from "zksync-sso/connector";
import { zksyncSepoliaTestnet } from "viem/chains";
import { createConfig, connect } from "@wagmi/core";
import { erc20Abi } from "viem";
const ssoConnector = zksyncSsoConnector({
// Optional session configuration,
// if omitted user will have to sign every transaction via Auth Server
session: {
expiry: "1 day",
// Allow up to 0.1 ETH to be spend in gas fees
feeLimit: parseEther("0.1"),
transfers: [
// Allow ETH transfers of up to 0.1 ETH to specific address
{
to: "0x188bd99cd7D4d78d4E605Aeea12C17B32CC3135A",
valueLimit: parseEther("0.1"),
},
],
// Allow calling specific smart contracts (e.g. ERC20 transfer):
contractCalls: [
callPolicy({
address: "0xa1cf087DB965Ab02Fb3CFaCe1f5c63935815f044",
abi: erc20Abi,
functionName: "transfer",
constraints: [
// Only allow transfers to this address. Or any address if omitted
{
index: 0, // First argument of erc20 transfer function, recipient address
value: "0x6cC8cf7f6b488C58AA909B77E6e65c631c204784",
},
// Allow transfering up to 0.2 tokens per hour
// until the session expires
{
index: 1,
limit: {
limit: parseUnits("0.2", TOKEN.decimals),
period: "1 hour",
},
},
],
}),
],
},
// Optional: Receive notifications about session state changes
onSessionStateChange: ({ state, address, chainId }) => {
console.log(`Session state for address ${address} changed: ${state.type} - ${state.message}`);
// Use this to notify users and restart the session if needed
// - Session expired: state.type === 'session_expired'
// - Session inactive (e.g. was revoked): eve.state.type === 'session_inactive'
},
});
const wagmiConfig = createConfig({
connectors: [ssoConnector],
..., // your wagmi config https://wagmi.sh/core/api/createConfig
});
const connectWithSSO = () => {
connect(wagmiConfig, {
connector: ssoConnector,
chainId: zksyncSepoliaTestnet.id, // or another chain id that has SSO support
});
};
Details
- zksync-sso
-
matter-labs
- about 2 months ago
- MIT
- 15 dependencies
Assets
- zksync-sso-0.4.0-beta.2.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0