Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d9c9a27
update to latest OZ, do not accept malleable signatures, add back sin…
gabspeck Apr 15, 2025
b297ef0
add SKA tests, further cleanup
gabspeck Apr 15, 2025
2ac0bb8
staticCall implementation on SingleKeyAccount
gabspeck Apr 15, 2025
a201b27
implement staticCall with timestamp-based challenge generation
gabspeck Apr 15, 2025
b090ab3
remove .cursorrules
gabspeck Apr 16, 2025
abf1fb9
test: propagation of revert errors from target calls
gabspeck Apr 16, 2025
332f14f
wagmi integration draft
gabspeck May 5, 2025
517cb43
deterministic create2 account factory deployment script
gabspeck May 5, 2025
4c0ab5e
use ignition module for CREATE2 deployment
gabspeck May 5, 2025
e91b0ce
working create2 deployment using ignition
gabspeck May 6, 2025
d88084a
wip provider code
gabspeck May 8, 2025
bd3d289
wip (not working)
gabspeck May 14, 2025
c3bb093
remove log
gabspeck May 14, 2025
5a7ba79
solve silent failure issue
gabspeck May 14, 2025
7574519
basic communication with account factory
gabspeck May 14, 2025
f6da054
check if account is deployed at deterministic create2 address
gabspeck May 15, 2025
2e5f292
working deployment of contract account
gabspeck May 15, 2025
83e5d19
wip: Giano execute call
gabspeck May 15, 2025
1fe5ab0
fix double encoding and add normalization of r/s coordinates
gabspeck May 16, 2025
50da8c2
workaround for gas underestimation issue
gabspeck May 16, 2025
d993387
move bulk of logic to giano provider
gabspeck May 16, 2025
b00c44e
authenticated eth_call (wip)
gabspeck May 16, 2025
9ec1489
prettier form in the demo app
gabspeck May 19, 2025
cfdf18c
fix low-S normalization
gabspeck May 19, 2025
7001ab5
improve ux of send message form
gabspeck May 19, 2025
3a3f187
remove debug log
gabspeck May 19, 2025
64cf1f4
export giano connector package
gabspeck May 19, 2025
e0682f0
fix pnpm version inconsistency
gabspeck May 19, 2025
e99d0ab
fix bug on disconnection
gabspeck May 20, 2025
a962e7d
replace implementation with Coinbase ERC-4337 account
gabspeck May 20, 2025
ba00191
move to entrypoint version 0.8
gabspeck May 20, 2025
096aa31
passing tests for 0.8
gabspeck May 20, 2025
4b838d0
ignore forge cache
gabspeck May 20, 2025
7886799
add bundler submodule and update ignition modules
gabspeck May 20, 2025
c33edb5
adapt toCoinbaseSmartWallet from viem
gabspeck May 20, 2025
82b055f
WIP convert viem coinbase code
gabspeck May 20, 2025
ec485bf
wip: ERC-4337
gabspeck May 21, 2025
7302218
working credential ID storage flow
gabspeck May 22, 2025
d1b1327
working provider and connector with ERC-4337
gabspeck May 22, 2025
b70842f
use alto as the bundler
gabspeck May 23, 2025
f0326a7
improve local dev setup
gabspeck May 23, 2025
8bdfb73
replace Coinbase references with Giano
gabspeck May 23, 2025
65b66f5
remove unnecessary values from user op gas estimation request
gabspeck May 23, 2025
b45c7b4
remove coinbase reference
gabspeck May 23, 2025
1f0ea99
wip signed static calls
gabspeck May 23, 2025
aed5316
last updates
gabspeck May 26, 2025
0a9afc5
update testing instructions
gabspeck May 26, 2025
137674a
update readme, remove obsolete code
gabspeck May 26, 2025
71be480
update demo start script and readme
gabspeck May 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"extends": [
"eslint-config-xs"
],
"extends": ["eslint-config-xs"],
"ignorePatterns": ["dist/"],
"rules": {
"node/no-missing-import": "off",
Expand All @@ -15,6 +13,7 @@
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-namespace": "off"
}
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/require-await": "off"
},
}
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
**/.env*
!**/.env.sample
.cursorrules
**/.env
dist/
node_modules/
.pnpm-store/
Expand All @@ -9,3 +9,5 @@ latest.sql
.DS_Store
.yarn/install-state.gz
.vite/
.next/
packages/contracts/generated.ts
18 changes: 18 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[submodule "packages/contracts/lib/forge-std"]
path = packages/contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "packages/contracts/lib/p256-verifier"]
path = packages/contracts/lib/p256-verifier
url = https://github.com/daimo-eth/p256-verifier
[submodule "packages/contracts/lib/webauthn-sol"]
path = packages/contracts/lib/webauthn-sol
url = https://github.com/base/webauthn-sol
[submodule "packages/contracts/lib/safe-singleton-deployer-sol"]
path = packages/contracts/lib/safe-singleton-deployer-sol
url = https://github.com/wilsoncusack/safe-singleton-deployer-sol
[submodule "packages/contracts/lib/solady"]
path = packages/contracts/lib/solady
url = https://github.com/Vectorized/solady
[submodule "vendor/account-abstraction"]
path = vendor/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
74 changes: 48 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,82 @@
<h1 align="center">Giano</h1>
</p>

This repository is a Proof of Concept showcasing how to use Passkey technology to authenticate users on a smart contract.
**Giano** is an ERC-4337-compliant smart wallet based on the [Coinbase Smart Wallet](https://github.com/coinbase/smart-wallet).

This repository is a demo showing how the user can authenticate on a smart contract using a Passkey.
## Development

Key parts:
### Setup

- [Login.tsx](./services/web/src/client/components/Login.tsx): authentication component to request account creation and session setting.
- [Wallet.tsx](./services/web/src/client/components/Wallet.tsx): main wallet component containing logic to mint and transfer ERC20/ERC721 tokens.
- [Account.sol](./packages/contracts/contracts/Account.sol): smart contract that implements a limited account abstraction mechanism
- [AccountFactory.sol](./packages/contracts/contracts/AccountFactory.sol): smart contract that deploys `Account` contracts on runtime and maps passkey IDs to `Account` contract addresses
1. Install [Foundry](https://getfoundry.sh/):

## Development
```sh
curl -L https://foundry.paradigm.xyz | bash
```

1. Install deps:
2. Initialize Git submodules:

```sh
yarn install
pnpm git:init
```

2. Start Hardhat node and deploy contracts:
3. Install deps:

```sh
yarn hh:node
yarn hh:deploy --network localhost
pnpm install
```

**Important**: The contract addresses are hard coded, so if you need to make any changes to the contracts, you must restart Hardhat before redeploying them.

3. Start application:
4. Start Anvil node:

```sh
yarn web:build:dev
pnpm hh:node
```

Application available at <http://localhost:3000>.
5. Deploy all the contracts:

```sh
pnpm hh:initlocal
```

### Test contracts:
6. Start the Alto bundler with CORS proxy:

```sh
yarn hh:test
pnpm bundler:dev
```
7. Start the demo app:
```sh
pnpm demo:dev
```

## Deployment
### Important tips

Until the official RIP-7212 P256 precompile at address `0x100` is more widespread, this contract relies on [this implementation](https://github.com/daimo-eth/p256-verifier).
- Remember to run `build` every time you make changes to the contracts or connector packages, so that changes are picked up by packages that import them
- Contracts are supposed to be deployed with Hardhat Ignition using a `CREATE2` strategy, that means the contracts' addresses will be the same on any chain and deployment order **as long as the generated bytecode remains the same**. That means, remember to restart Anvil and run `hh:initlocal` again every time you change the contracts. Also, don't forget to update the constants in the connector code and rebuild the package.

It is deterministically deployed at address `0xc2b78104907F722DABAc4C69f826a522B2754De4` on all major chains.

If you need to deploy it to a new chain, run the appropriate script:
Application available at <http://localhost:3000>.

```bash
pnpm hardhat run scripts/p256_deploy.ts --network <network name>
### Test contracts

#### Coinbase tests (Foundry-based)
```sh (Foundry-based)
forge test
```

#### Hardhat tests
```sh
pnpm hh:test
```

## Components

- `GianoSmartWallet`: the smart wallet itself, which validates the signatures and executes the calls.
- `GianoSmartWalletFactory`: the contract responsible for deploying the smart wallet contracts
- `CredentialKeyMapper`: the contract that stores a mapping between WebAuthn credential IDs and the public key of each. Needed because WebAuthn public keys are only returned on creation, not retrieval.
- `toGianoSmartAccount.ts`: module that instantiates a Viem client for the Giano Smart Wallet
- `provider.ts`: `EIP-1193`-compatible provider that intercepts EVM RPC requests and repackages transactions as user ops to be passed to the bundler
- `connector.ts`: WAGMI connector
- `gianoWallet.ts`: RainbowKit integration code

## Setting up Blockscout (block explorer)

If you want, you can use `docker compose` to start up a local Blockscout instance to explore the transactions and
Expand Down
9 changes: 9 additions & 0 deletions alto-local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entrypoints": "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",
"_executor-private-keys": "0x211899abe67f2ef5fc79849d05fd075a4c0150d0ff517946a0a1c257136153fa",
"executor-private-keys": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"utility-private-key": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"rpc-url": "http://localhost:8545",
"rpc-log-level": "trace",
"safe-mode": false
}
21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
{
"name": "@appliedblockchain/giano",
"private": true,
"packageManager": "[email protected]",
"scripts": {
"build": "pnpm -r build",
"demo:dev": "pnpm -F @appliedblockchain/giano-example dev",
"build:connector": "pnpm -F @appliedblockchain/giano-connector build",
"git:init": "git submodule update --init --recursive",
"bundler:start": "alto --config ./alto-local.json",
"bundler:cors": "lcp --proxyUrl http://localhost:3000 --port 4337",
"bundler:dev": "npm-run-all -p --race bundler:start bundler:cors",
"aa:deploy:local": "cd vendor/account-abstraction && env COREPACK_ENABLE_STRICT=0 corepack yarn@1 && env COREPACK_ENABLE_STRICT=0 corepack yarn@1 deploy --network localhost",
"hh:initlocal": "pnpm --filter @appliedblockchain/giano-contracts hh:initlocal",
"hh:node": "pnpm --filter @appliedblockchain/giano-contracts hh:node",
"hh:deploy": "pnpm --filter @appliedblockchain/giano-contracts hh:deploy",
"hh:deploy:testing": "pnpm --filter @appliedblockchain/giano-contracts hh:deploy:testing"
},
"devDependencies": {
"@pimlico/alto": "^0.0.18",
"local-cors-proxy": "^1.1.0",
"npm-run-all": "^4.1.5",
"tsup": "^8.3.5"
}
},
"packageManager": "[email protected]+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
}
1 change: 0 additions & 1 deletion packages/client/index.ts

This file was deleted.

25 changes: 0 additions & 25 deletions packages/client/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/client/src/wallet/index.ts

This file was deleted.

85 changes: 0 additions & 85 deletions packages/client/src/wallet/walletClient.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/common/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/common/package.json

This file was deleted.

28 changes: 0 additions & 28 deletions packages/common/src/encoding/encodeChallenge.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/common/src/encoding/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/common/src/encoding/numbers.ts

This file was deleted.

Loading