Skip to content

Commit 894b485

Browse files
Update READMEs
* update READMEs * Fix typo Co-authored-by: jeffsmale90 <6363749+jeffsmale90@users.noreply.github.com> --------- Co-authored-by: jeffsmale90 <6363749+jeffsmale90@users.noreply.github.com>
1 parent ea5f0fb commit 894b485

2 files changed

Lines changed: 29 additions & 100 deletions

File tree

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
# DeleGator SDK Monorepo
22

3-
This monorepo consists of a suite of tools to enable developers to build using the MetaMask Delegation system and DeleGator Smart Contract Accounts.
3+
This monorepo consists of a suite of tools to enable developers to build using the MetaMask Smart Contract Accounts, and Delegation system.
44

55
### Project Structure
66

77
- `./packages` contains top level packages that will be deployed for external use
8-
- `/delegation-abis` a bundle of ABIs mapping to a specific version of the [Delegation Framework](https://github.com/metamask/delegation-framework).
9-
- `/delegation-deployments` a history of deployments of various versions of the [Delegation Framework](https://github.com/metamask/delegation-framework).
10-
- `/delegation-toolkit` utilities for interacting with a [DeleGator SCA](https://github.com/MetaMask/delegation-framework/blob/main/documents/HybridDeleGator.md) as a viem [Wallet Client](https://viem.sh/docs/clients/wallet#wallet-client).
11-
- `/delegator-e2e` end-to-end tests for the Delegation Toolkit.
12-
- `./shared` contains simple shared resources for configuring and testing the packages.
8+
- `/delegation-abis` has collection of ABIs corresponding to a specific version of the [Delegation Framework](https://github.com/metamask/delegation-framework).
9+
- `/delegation-deployments` contains deployments for different versions of the [Delegation Framework](https://github.com/metamask/delegation-framework).
10+
- `/delegation-toolkit` has utilities for creating a [DeleGator SCA](https://github.com/MetaMask/delegation-framework/blob/main/documents/DeleGatorCore.md#metamasks-delegatorcore) know as MetaMask smart account, setting up delegations, and redeeming them.
11+
- `/delegator-e2e` has end-to-end tests for the Delegation Toolkit.
12+
- `./shared` contains basic shared resources for configuring and testing the packages.
1313

14-
## Development
14+
## Getting Started
1515

16-
### Quick Start
16+
To get started with the monorepo, please make sure to review the [requirements](/CONTRIBUTING.md#requirements).
1717

1818
```sh
1919
yarn install && yarn dev
2020
```
2121

22-
### Contributing
22+
## Contributing
2323

24-
See the contribution guide [here](/CONTRIBUTING.md)
24+
If you are interested in contributing, please [see the contribution guide](/CONTRIBUTING.md#Contributing).
2525

2626
## Useful Links
2727

@@ -36,6 +36,6 @@ See the contribution guide [here](/CONTRIBUTING.md)
3636
- [EIP-1967](https://eips.ethereum.org/EIPS/eip-1967)
3737
- [EIP-4337](https://eips.ethereum.org/EIPS/eip-4337)
3838
- [EIP-7201](https://eips.ethereum.org/EIPS/eip-7201)
39-
- ERC-7710
40-
- ERC-7715
39+
- [ERC-7710](https://eips.ethereum.org/EIPS/eip-7710)
40+
- [ERC-7715](https://eips.ethereum.org/EIPS/eip-7715)
4141
- [EIP-7212](https://eips.ethereum.org/EIPS/eip-7212)
Lines changed: 17 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MetaMask Delegation Toolkit
22

3-
The MetaMask Delegation Toolkit is built on top of [viem](https://viem.sh) which enables developers to create smart accounts and frictionless new experiences based on granular permission sharing and trust.
3+
The MetaMask Delegation Toolkit is a [Viem](https://viem.sh)-based collection of tools for integrating MetaMask embedded smart account and create frictionless new experiences based on granular permission sharing and trust.
44

55
## Features
66
---
@@ -15,23 +15,21 @@ The MetaMask Delegation Toolkit is built on top of [viem](https://viem.sh) which
1515
---
1616

1717
Yarn:
18-
```
18+
```sh
1919
yarn add @metamask/delegation-toolkit
2020
```
2121

2222
Npm:
23-
```
23+
```sh
2424
npm install @metamask/delegation-toolkit
2525
```
2626

27-
## Usage
27+
## Overview
2828
---
2929

30-
### Create a Smart Account
31-
3230
```ts
3331
import { createPublicClient, http } from "viem";
34-
import { lineaSepolia as chain } from "viem/chains";
32+
import { sepolia as chain } from "viem/chains";
3533
import { privateKeyToAccount } from "viem/accounts";
3634
import {
3735
Implementation,
@@ -43,93 +41,17 @@ const publicClient = createPublicClient({
4341
transport: http(),
4442
});
4543

46-
const delegatorAccount = privateKeyToAccount("0x...");
44+
const account = privateKeyToAccount("0x...");
4745

48-
const delegatorSmartAccount = await toMetaMaskSmartAccount({
46+
const smartAccount = await toMetaMaskSmartAccount({
4947
client: publicClient,
5048
implementation: Implementation.Hybrid,
51-
deployParams: [delegatorAccount.address, [], [], []],
49+
deployParams: [account.address, [], [], []],
5250
deploySalt: "0x",
53-
signatory: { account: delegatorAccount },
54-
});
55-
```
56-
57-
### Create a Delegation
58-
59-
```ts
60-
import { createDelegation } from "@metamask/delegation-toolkit";
61-
62-
// Delegate account can either be a Smart Account or an EOA.
63-
const delegateAccount = "0x1ac.."
64-
65-
const delegation = createDelegation({
66-
to: delegateAccount,
67-
from: delegatorSmartAccount.address,
68-
// Empty caveats array - we recommend adding appropriate restrictions.
69-
caveats: createCaveatBuilder({
70-
environment,
71-
allowEmptyCaveats: true,
72-
}),
73-
});
74-
75-
// Sign the delegation using delegator's smart account.
76-
const signature = await delegatorSmartAccount.signDelegation({
77-
delegation
51+
signatory: { account },
7852
});
79-
80-
const signedDelegation = {
81-
...delegation,
82-
signature,
83-
};
8453
```
8554

86-
### Redeem a Delegation
87-
88-
```ts
89-
import { createBundlerClient } from "viem/account-abstraction";
90-
import {
91-
createExecution,
92-
DelegationFramework,
93-
SINGLE_DEFAULT_MODE,
94-
} from "@metamask/delegation-toolkit";
95-
import { zeroAddress } from "viem";
96-
97-
const bundlerClient = createBundlerClient({
98-
client: publicClient,
99-
transport: http("https://your-bundler-rpc.com"),
100-
});
101-
102-
// Use the signed delegation
103-
const delegations = [ signedDelegation ];
104-
105-
// Sends 0 ETH to zero address(0x0000000000000000000000000000000000000000)
106-
const executions = [{
107-
target: zeroAddress,
108-
value: 0n,
109-
callData: "0x"
110-
}];
111-
112-
const redeemDelegationCalldata = DelegationFramework.encode.redeemDelegations({
113-
delegations: [ delegations ],
114-
modes: [ SINGLE_DEFAULT_MODE ],
115-
executions: [ executions ]
116-
});
117-
118-
// Assuming delegate account is a smart account. To learn how to redeem a
119-
// delegation with EOA, please head to the documentation.
120-
// https://docs.gator.metamask.io/how-to/redeem-delegation#redeem-with-an-eoa
121-
const userOperationHash = await bundlerClient.sendUserOperation({
122-
account: delegateSmartAccount,
123-
calls: [
124-
{
125-
to: delegateSmartAccount.address,
126-
data: redeemDelegationCalldata
127-
}
128-
],
129-
maxFeePerGas: 1n,
130-
maxPriorityFeePerGas: 1n,
131-
});
132-
```
13355

13456
## Documentation
13557
---
@@ -138,4 +60,11 @@ const userOperationHash = await bundlerClient.sendUserOperation({
13860
## Contributing
13961
---
14062

141-
If you're interested in contributing, please see our full [contributing guide](/CONTRIBUTING.md).
63+
If you are interested in contributing, please [see the contribution guide](/CONTRIBUTING.md#Contributing).
64+
65+
66+
## Useful Links
67+
- [Delegation Toolkit Quick start](https://docs.metamask.io/delegation-toolkit/get-started/quickstart/)
68+
- [Delegation Toolkit CLI Quick start](https://docs.metamask.io/delegation-toolkit/development/get-started/cli-quickstart/)
69+
- [Scaffold ETH extension](https://github.com/metamask/gator-extension)
70+
- [API reference](https://docs.metamask.io/delegation-toolkit/development/reference/)

0 commit comments

Comments
 (0)