diff --git a/ERCS/erc-7715.md b/ERCS/erc-7715.md index cf71693b28..de1df42474 100644 --- a/ERCS/erc-7715.md +++ b/ERCS/erc-7715.md @@ -368,7 +368,62 @@ sequenceDiagram #### ERC-7710 -TODO +When requesting permissions with a `type` of `account`, the returned data will be redeemable using the interfaces specified in ERC-7710. This allows the recipient of the permissions to use any account type (EOA or contract) to form a transaction or UserOp using whatever payment or relay infrastructure they prefer, by sending an internal message to the returned `permissions.signerData.submitToAddress` and calling its `function redeemDelegation(bytes calldata _data, Action calldata _action) external;` function with the `_data` parameter set to the returned `permissions.permissionsContext`, and the `_action` data forming the message that the permissions recipient desires the user's account to emit, as defined by this struct: + +``` +struct Action { + address to; + uint256 value; + bytes data; +} +``` + +A simple pseudocode example of using a permission in this way, given two ethers signers in the same context, where `alice` wants to request a permission from `bob` might be like this: + +``` +// Alice requests a permission from Bob +const permissionsResponse = await bob.request({ + method: 'wallet_issuePermissions', + params: [{ + signer: { + type: 'account', + data: { + id: bob.address + } + }, + permissions: [{ + type: 'native-token-limit', + data: { + amount: ethers.utils.parseEther('1.0') + }, + required: true + }], + expiry: Math.floor(Date.now() / 1000) + 3600 // 1 hour from now + }] +}); + +// Extract the permissionsContext and submitToAddress +const permissionsContext = permissionsResponse.permissionsContext; +const submitToAddress = permissionsResponse.signerData.submitToAddress; + +// Alice forms the action she wants Bob's account to take +const action = { + to: alice.address, + value: ethers.utils.parseEther('0.5'), + data: '0x' +}; + +// Alice sends the transaction by calling redeemDelegation on Bob's account +const tx = await bob.sendTransaction({ + to: submitToAddress, + data: bob.interface.encodeFunctionData('redeemDelegation', [ + permissionsContext, + action + ]) +}); + +await tx.wait(); +``` ## Rationale