diff --git a/code/webauthn/README.md b/code/webauthn/README.md index 2ccbc261..2ac0f0b8 100644 --- a/code/webauthn/README.md +++ b/code/webauthn/README.md @@ -6,8 +6,8 @@ This demo requires Google Chrome and a device that supports webauthn. ### Install Dependencies +Use node version `20.16.0`. Run `npm install` in both the `frontend` and `contracts` folders. -Node version 20 is required. ### Start a local node @@ -19,13 +19,25 @@ era_test_node run ### Deploying the Contracts +Make a `.env` file and add a private key for a [pre-configured rich wallet](https://docs.zksync.io/build/test-and-debug/in-memory-node#pre-configured-rich-wallets). + +```env +WALLET_PRIVATE_KEY=<0x_YOUR_PRIVATE_KEY> +``` + Deploy the AAFactory, paymaster, and NFT contracts: ```shell npm run deploy ``` -Once deployed, update the addresses in `frontend/utils/constants.ts`. +Once deployed, create a `frontend/.env.local` file based example in `frontend/.env.example` and add the deployed addresses. + +```env +NEXT_PUBLIC_AA_FACTORY_ADDRESS=<0x_YOUR_AA_CONTRACT_ADDRESS> +NEXT_PUBLIC_NFT_CONTRACT_ADDRESS=<0x_YOUR_NFT_CONTRACT_ADDRESS> +NEXT_PUBLIC_PAYMASTER_ADDRESS=<0x_YOUR_PAYMASTER_CONTRACT_ADDRESS> +``` ### Deploying a New Smart Account diff --git a/code/webauthn/contracts/deploy/deploy.ts b/code/webauthn/contracts/deploy/deploy.ts index 13987aed..28e139d6 100644 --- a/code/webauthn/contracts/deploy/deploy.ts +++ b/code/webauthn/contracts/deploy/deploy.ts @@ -1,6 +1,5 @@ import { utils, Wallet, Provider } from 'zksync-ethers'; import type { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { Deployer } from '@matterlabs/hardhat-zksync'; // load env file import dotenv from 'dotenv'; import { ethers } from 'ethers'; @@ -12,29 +11,31 @@ export default async function (hre: HardhatRuntimeEnvironment) { // @ts-expect-error target config file which can be testnet or local const provider = new Provider(hre.network.config.url); const wallet = new Wallet(DEPLOYER_PRIVATE_KEY, provider); - const deployer = new Deployer(hre, wallet); // deploy the AA Factory & test deploying an account - await deployAAFactory(deployer); + await deployAAFactory(hre.deployer); // deploy the NFT contract - await deployMyNFT(deployer); + await deployMyNFT(hre.deployer); // deploy the Paymaster contract - await deployPaymaster(deployer, wallet); + await deployPaymaster(hre.deployer, wallet); } -async function deployAAFactory(deployer: Deployer) { +async function deployAAFactory(deployer: HardhatRuntimeEnvironment['deployer']) { const factoryArtifact = await deployer.loadArtifact('AAFactory'); const aaArtifact = await deployer.loadArtifact('Account'); - const factory = await deployer.deploy(factoryArtifact, [utils.hashBytecode(aaArtifact.bytecode)], undefined, [ - aaArtifact.bytecode, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ] as any); + const factory = await deployer.deploy( + factoryArtifact, + [utils.hashBytecode(aaArtifact.bytecode)], + undefined, + undefined, + [aaArtifact.bytecode] + ); const factoryAddress = await factory.getAddress(); console.log(`AA factory address: ${factoryAddress}`); } -async function deployMyNFT(deployer: Deployer) { +async function deployMyNFT(deployer: HardhatRuntimeEnvironment['deployer']) { const artifact = await deployer.loadArtifact('MyNFT'); // eslint-disable-next-line @typescript-eslint/no-explicit-any const constructorArguments: any[] = []; @@ -46,7 +47,7 @@ async function deployMyNFT(deployer: Deployer) { console.log('DONE MINTING'); } -async function deployPaymaster(deployer: Deployer, wallet: Wallet) { +async function deployPaymaster(deployer: HardhatRuntimeEnvironment['deployer'], wallet: Wallet) { const artifact = await deployer.loadArtifact('GeneralPaymaster'); // eslint-disable-next-line @typescript-eslint/no-explicit-any const constructorArguments: any[] = []; diff --git a/content/tutorials/signing-transactions-with-webauthn/10.index.md b/content/tutorials/signing-transactions-with-webauthn/10.index.md index fd3dc5f9..027b9825 100644 --- a/content/tutorials/signing-transactions-with-webauthn/10.index.md +++ b/content/tutorials/signing-transactions-with-webauthn/10.index.md @@ -8,7 +8,7 @@ description: Learn how to sign transactions with WebAuthn. - Make sure your machine satisfies the [system requirements](https://github.com/matter-labs/era-compiler-solidity/tree/main#system-requirements). - You should have the latest version of Google Chrome installed. -- You should have [Node.js](https://nodejs.org/en/download) installed. +- You should have [Node.js](https://nodejs.org/en/download) version `20.16.0` installed. - You should have [`era_test_node`](https://docs.zksync.io/build/test-and-debug/in-memory-node#install-and-set-up-era_test_node) installed. - If you aren't familiar with paymasters and smart accounts on ZKsync Era, check out the [General Paymaster](https://docs.zksync.io/build/start-coding/zksync-101/paymaster) and diff --git a/content/tutorials/signing-transactions-with-webauthn/20.building-the-contracts.md b/content/tutorials/signing-transactions-with-webauthn/20.building-the-contracts.md index dac2aef7..4a8e218f 100644 --- a/content/tutorials/signing-transactions-with-webauthn/20.building-the-contracts.md +++ b/content/tutorials/signing-transactions-with-webauthn/20.building-the-contracts.md @@ -207,7 +207,7 @@ Finally, it calls the `callVerifier` function to call the `P256Verify` precompil The `callVerifier` function encodes the input into the correct format and calls the `P256Verify` precompile. -If the returned output is empty, the validation evaluated to false. +If the returned output is empty, the precompile validation evaluated to false. This means that the public key derived from the WebAuthn signature does not match the registered `r1Owner` public key. The output data should be 1 (in 32 bytes format) if the signature verification process succeeds, or nothing if it fails.