Skip to content

Commit fd85eb8

Browse files
chore: update contract deployment docs (#63)
* chore: update contract deployment docs We don't use nx in the contract repo, so these deploy instructions need a little update. * docs: explain how auth server uses sdk The deployment for new chains is a little short on details, but that's probably better to include in zkstack cli, since those tools are outside of this repo --------- Co-authored-by: yuliyaalexiev <158060999+yuliyaalexiev@users.noreply.github.com>
1 parent 743bfbc commit fd85eb8

File tree

5 files changed

+66
-7
lines changed

5 files changed

+66
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ To execute the end-to-end tests for the `demo-app` (or similarly for
199199

200200
1. Start `era_test_node` (In a separate terminal, run
201201
`npx zksync-cli dev start`)
202-
2. Deploy the smart contracts, `pnpm nx deploy contracts`
202+
2. Deploy the smart contracts, `pnpm --dir packages/contracts run deploy`
203203

204204
Once the local node is configured with the smart contracts deployed, you can run
205205
the e2e tests:

docs/nx-cheatsheet.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ in the workspace's `project.json`, not the directory name.
1111
```bash
1212
pnpm nx <target> <project>
1313
# examples
14-
# pnpm nx deploy contracts
1514
# pnpm nx serve auth-server
1615
# pnpm nx build sdk
1716
```

examples/bank-demo/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ Account session and data is stored via the browser Local storage.
2626

2727
## Deploying the Bank demo to Firebase
2828

29-
The Bank demo app uses Demo Node (`https://node.nvillanueva.com`).
29+
The Bank demo app uses Demo Node (`https://node.nvillanueva.com`). Add your
30+
deployer private key to the .env file (packages/contracts/.env)
3031

3132
1. Deploy the latest contracts with
32-
`pnpm nx deploy contracts -- --network demoNode`.
33+
34+
`pnpm --dir packages/contracts run deploy --network demoNode`.
3335

3436
2. Update `nuxt.config.ts` contract addresses under `$production`.
3537

examples/nft-quest/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Run the following (be sure a local node is running, e.g.
88
`era_test_node`[https://docs.zksync.io/build/zksync-cli/running-a-node]):
99

1010
```sh
11-
# Deploy the ZKsync SSO contracts
12-
pnpm nx deploy contracts
11+
# Deploy the ZKsync SSO contracts (when run from the root)
12+
pnpm --dir packages/contracts run deploy
1313

1414
# Deploy the contracts for the NFT Quest Demo
1515
pnpm nx deploy:local nft-quest-contracts

packages/auth-server/README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,66 @@ ZKsync SSO Auth Server
77
```sh
88
# Ensure era_test_node is already running (npx zksync-cli dev start)
99
# Deploy ZKsync SSO smart contracts
10-
pnpm nx deploy contracts
10+
pnpm --dir packages/contracts run deploy
1111

1212
# Start Auth Server
1313
pnpm nx dev auth-server
1414
```
15+
16+
## How to deploy to a new chain
17+
18+
If you are a ZKsync chain operator, there are a few more updates to make to
19+
deploy.
20+
21+
Deploy the timestamp asserter and update the TimestampLocator.sol with your
22+
chain id.
23+
24+
Adding contracts to the storage slot allow list (api_web3_json_rpc:
25+
whitelisted_tokens_for_aa)
26+
27+
Include the addresses of SSO WebAuthValidator, SSO SessionKeyValidator, SSO
28+
Beacon which need to be updated by the chain id in contractsByChain in the
29+
client file. The block explorer url in the same file can also be updated if your
30+
chain is listed in viem/chains.
31+
32+
## Design
33+
34+
The auth server is designed to run as a static front-end that facilitates
35+
passkey signing and session creation via a trusted domain. The SDK has a wagmi
36+
connector that points users to this project.
37+
38+
### Communication
39+
40+
The auth-server expects to managed via pop-up, so the client-auth-server uses
41+
the pop-up communicator component to send the transaction request via
42+
window.postMessage. The auth-server listens to this message and the loads the
43+
UI, which then drives the user either through the sign-in with passkey or create
44+
account flow.
45+
46+
It uses a custom RPC format to send success and status messages back to the SDK
47+
for the session request data.
48+
49+
### Account Deployment
50+
51+
The account deployment and on-chain interaction for passkey signing and session
52+
creation both happen within the auth server (session key signing happens
53+
outside). This requires that the auth-server is connected to a paymaster, as the
54+
deployment is performed from a random address for each deployment.
55+
56+
The auth server _currently_ uses the passkey credential id as the unique account
57+
id if it's not provided, it then checks the account deployment factory to log a
58+
user in as the factory stores a mapping from passkey id to account address.
59+
60+
### Dashboard
61+
62+
The auth server expects both the session key and passkey module to be installed,
63+
so builds in dashboards for the modules to view basic information on sessions
64+
and passkeys. It depends on the SDK's definition of SessionConfig to parse the
65+
session for the user before approval. It reads the session status directly from
66+
the chain and then relies on the SDK's contract ABI for the session key
67+
validation module.
68+
69+
### Storage
70+
71+
To reduce user friction after signing in or signing up, the account information
72+
is kept in browser local storage tied to the auth server domain.

0 commit comments

Comments
 (0)