Skip to content

Commit e25f4dd

Browse files
improve code snippets
1 parent 67367e2 commit e25f4dd

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

delegation-toolkit/get-started/quickstart.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,7 @@ import { zeroAddress } from "viem";
146146

147147
const delegations = [ signedDelegation ];
148148

149-
const executions = [{
150-
target: zeroAddress,
151-
value: 0n,
152-
callData: "0x"
153-
}];
149+
const executions = createExecution(zeroAddress);
154150

155151
const redeemDelegationCalldata = DelegationFramework.encode.redeemDelegations({
156152
delegations: [ delegations ],

delegation-toolkit/how-to/create-smart-account/configure-accounts-signers.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This example creates a signatory from a private key using Viem's [`privateKeyToA
4848

4949
```typescript
5050
import { publicClient } from "./client.ts"
51-
import { signatory } from "./signatory.ts";
51+
import { account } from "./signatory.ts";
5252
import {
5353
Implementation,
5454
toMetaMaskSmartAccount,
@@ -57,9 +57,9 @@ import {
5757
const smartAccount = await toMetaMaskSmartAccount({
5858
client: publicClient,
5959
implementation: Implementation.Hybrid,
60-
deployParams: [owner, p256KeyIds, p256XValues, p256YValues],
60+
deployParams: [account.address, [], [], []],
6161
deploySalt: "0x",
62-
signatory,
62+
signatory: { account },
6363
});
6464
```
6565

@@ -86,9 +86,7 @@ export const publicClient = createPublicClient({
8686
import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";
8787

8888
const privateKey = generatePrivateKey();
89-
const account = privateKeyToAccount(privateKey);
90-
91-
export const signatory = { account };
89+
export const account = privateKeyToAccount(privateKey);
9290
```
9391

9492
</TabItem>
@@ -104,18 +102,20 @@ using Viem's `createWalletClient` function.
104102

105103
```typescript
106104
import { publicClient } from "./client.ts"
107-
import { signatory } from "./signatory.ts";
105+
import { walletClient } from "./signatory.ts";
108106
import {
109107
Implementation,
110108
toMetaMaskSmartAccount,
111109
} from "@metamask/delegation-toolkit";
112110

111+
const owner = walletClient.account.address;
112+
113113
const smartAccount = await toMetaMaskSmartAccount({
114114
client: publicClient,
115115
implementation: Implementation.Hybrid,
116-
deployParams: [owner, p256KeyIds, p256XValues, p256YValues],
116+
deployParams: [owner, [], [], []],
117117
deploySalt: "0x",
118-
signatory,
118+
signatory: { walletClient },
119119
});
120120
```
121121

@@ -146,13 +146,11 @@ import { http, createWalletClient } from "viem";
146146
const privateKey = generatePrivateKey();
147147
const account = privateKeyToAccount(privateKey);
148148

149-
const walletClient = createWalletClient({
149+
export const walletClient = createWalletClient({
150150
account,
151151
chain,
152152
transport: http()
153153
})
154-
155-
export const signatory = { walletClient };
156154
```
157155

158156
</TabItem>

delegation-toolkit/how-to/send-user-operation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ The following example updates the previous example to estimate the fees.
109109
This example uses constant values, but the [Hello Gator example](https://github.com/MetaMask/hello-gator) uses Pimlico's Alto bundler,
110110
which fetches user operation gas price using the RPC method [`pimlico_getUserOperationPrice`](https://docs.pimlico.io/infra/bundler/endpoints/pimlico_getUserOperationGasPrice).
111111

112+
:::info Installation required
113+
114+
To estimate the gas fee, we'll use the [permissionless.js](https://docs.pimlico.io/references/permissionless/) SDK. Please make sure the SDK is installed.
115+
116+
:::
117+
112118
```typescript title="example.ts"
113119
// add-next-line
114120
+ import { createPimlicoClient } from "permissionless/clients/pimlico";

0 commit comments

Comments
 (0)