From 8723ac428f331b077d6356b2f007d30a0f21f00c Mon Sep 17 00:00:00 2001 From: Derek Chiang Date: Thu, 26 Oct 2023 19:38:09 -0700 Subject: [PATCH] Finish removing session key docs --- README.md | 108 ------------------------------------------------------ 1 file changed, 108 deletions(-) diff --git a/README.md b/README.md index 9896d4fb..0a56edc6 100644 --- a/README.md +++ b/README.md @@ -416,114 +416,6 @@ const { hash } = await erc165SessionKeyProvider.sendUserOperation({ ### Session Key Validator -```ts -// 1. Get the default ecdsa validator provider -const ecdsaProvider = await ECDSAProvider.init({ - projectId, // zeroDev projectId - owner, -}); - -// 2. Initialize SessionKey Validator Provider -const sessionKey = LocalAccountSigner.privateKeyToAccountSigner(); -const accountAddress = await ecdsaProvider.getAccount().getAddress(); -const sig = getFunctionSelector( - "transfer(address, uint256)" - ) -const permissions = [ - getPermissionFromABI({ - target: , // address of the target contract, - valueLimit: 0n, // max value the session key can use in tx -- (Default: 0) - operation: Operation.Call, // The kind of call session key can make CALL/DELEGATECALL (Default: Operation.Call) - abi: TEST_ERC20Abi, // Abi of the target contract - functionName: "transfer", // The function that can be called on the target contract - args: [, 10000n], // The value to check in condition - conditions: [ - ParamCondition.EQUAL, - ParamCondition.LESS_THAN_OR_EQUAL, - ], // The condition to check - - // To allows specific params to not have any condition pass `null` in the param position in the `args` and `conditions` like below: - - // args: [, null], // The value to check in condition - // conditions: [ - // ParamCondition.EQUAL, - // null - // ], // The condition to check - }) -] - -const sessionKeyProvider = await SessionKeyProvider.init({ - projectId, //ZeroDevProject - defaultProvider: ecdsaProvider, // Pass the ECDSAProvider as default provider - sessionKey, // Session Key Signer - sessionKeyData: { - validAfter: 0, // (Default: 0) - validUntil: 0, // (Default: 0) - permissions, - paymaster, // Paymaster Address : zeroAddress means accept userOp without paymaster, oneAddress means reject userOp without paymaster, other address means accept userOp with paymaster with the address // (Default: zeroAddress) - } -}); - -// 3. Send the transaction -const { hash } = await sessionKeyProvider.sendUserOperation({ - target: ERC20Address, - data: encodeFunctionData({ - abi: TEST_ERC20Abi, - functionName: "transfer", - args: ["RECIPIENT_ADDRESS", "AMOUNT_TO_TRANSFER"], - }), -}); -``` - -> **_NOTE:_** If you are using ERC20 Token Paymaster along with Session Key then make sure to also whitelist the Multisend contract address and function selector in the permissions alongwith with end contract permission as below. - -```ts -import { constants, MultiSendAbi } from "@zerodev/sdk"; - -// Permission object to pass in the `sessionKeyData.permissions` array -const permissions = [ - ..., - getPermissionFromABI({ - target: MULTISEND_ADDR, - abi: MultiSendAbi, - functionName: "multiSend", - operation: Operation.DelegateCall - }), -] -``` - -#### Creating Session Key on the server and using it on the client side - -```ts -// 1. Initilize the session key provider -const sessionKeyProvider = await SessionKeyProvider.init({ - projectId, //ZeroDevProject - defaultProvider: ecdsaProvider, - sessionKey, // Session Key Signer - sessionKeyData: { - validAfter: 0, - validUntil: 0, - permissions, - paymaster, // Paymaster Address : zeroAddress means accept userOp without paymaster, oneAddress means reject userOp without paymaster, other address means accept userOp with paymaster with the address - } -}); - -// 2. Serialize the session key params with the private key and send it to the client -const serializedSessionKeyParams = await sessionKeyProvider.serializeSessionKeyParams(); - -// On client side -// 3. Deserialize the session key params -const sessionKeyParams = SessionKeyProvider.deserializeSessionKeyParams(serializedSessionKeyParams); - -// 4 Initialize the SessionKey Provider from the session key params -const sessionKeyProvider = await SessionKeyProvider.fromSessionKeyParams({ - projectId, //ZeroDevProject - sessionKeyParams - }); -``` - -#### Creating Session Key on the client and approving on the server - [Please check out the session key docs here.](https://docs.zerodev.app/use-wallets/use-session-keys) ### Recovery Key Validator