Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ is ever held in the app.

You will need:

- a viem `WalletClient` connected to the target chain,
- a viem `WalletClient` connected to the target chain, carrying an `account`
and an explicit RPC URL (see the note under the example),
- the passkey `credentialId` and `rpId` registered for the device,
- a Pimlico API key and a gas policy id (used by the bundler and paymaster).

Expand All @@ -48,7 +49,11 @@ import { Kokio } from "kokio-sdk";
import { createWalletClient, http } from "viem";
import { baseSepolia } from "viem/chains";

const walletClient = createWalletClient({ chain: baseSepolia, transport: http() });
const walletClient = createWalletClient({
account: knownAddress,
chain: baseSepolia,
transport: http(rpcUrl),
});

const kokio = new Kokio(
walletClient,
Expand Down Expand Up @@ -81,9 +86,20 @@ const session = new Kokio(

// 4. Send a user operation. The passkey signs it on the device.
const hash = await session.deviceWallet!.toggleAccessToFunds(eSIMWalletAddress, true);
await smartAccountClient.waitForUserOperationTransaction({ hash });
const receipt = await smartAccountClient.waitForUserOperationReceipt({ hash });
if (!receipt.success) throw new Error("operation reverted");
```

Two things about the wallet client. It has to carry an `account`:
`getSmartWallet` refuses a client without one, though it never asks it for a
signature, since the passkey signs everything. And give `http()` a real RPC
URL, because the SDK reads `client.transport.url` to build the public client
it uses for contract reads.

Check `receipt.success`. An operation whose calls revert is still mined and
still returns a receipt, so the await resolving is not on its own proof the
write landed. `receipt.receipt.transactionHash` is the onchain transaction.

The contract surfaces (`deviceWallet`, `eSIMWallet`, `deviceWalletFactory`,
`eSIMWalletFactory`, `registry`, `paymentAdapter`, `P256Verifier`) are only
present once a `smartAccountClient` is supplied, which is why the example
Expand Down
6 changes: 5 additions & 1 deletion docs/mobile/device-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ operation signed by the passkey.

```ts
const hash = await kokio.deviceWallet!.toggleAccessToFunds(eSIMWalletAddress, true);
await smartAccountClient.waitForUserOperationTransaction({ hash });
const receipt = await smartAccountClient.waitForUserOperationReceipt({ hash });
if (!receipt.success) throw new Error("operation reverted");
```

An operation whose calls revert is still mined and still returns a receipt,
so check `success` rather than treating a resolved await as confirmation.

## sendUserOperation

Sends one or more raw calls from this device wallet as a single user
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kokio-sdk",
"version": "3.0.0",
"version": "3.0.1",
"description": "",
"type": "module",
"main": "./dist/esm/config.js",
Expand Down
Loading