diff --git a/docs/walletkit/android/gas-abstraction.mdx b/docs/walletkit/android/gas-abstraction.mdx new file mode 100644 index 00000000..e833b2a0 --- /dev/null +++ b/docs/walletkit/android/gas-abstraction.mdx @@ -0,0 +1,72 @@ +# Gas Abstraction (experimental) + +WalletKit provides a toolkit for wallet developers to integrate verifying paymaster gas abstraction into their wallets. + +`GasAbstractionClient` is instantiated with some basic RPC URL and API key information. This client is long-lived and should be reused between transactions as it will reuse network connections for improved latency. + +When receiving a transaction request, send the transaction to the `prepare_gas_abstraction(txn)` method. This will do some thinking and will prepare a set of operations and return a couple of hashes to be signed. + +The operations are: + +1. Deploying the 7702 account and delegating to it, if needed +2. Sending a sponsored UserOperation for the initial transaction. + +The user will then approve signatures for these operations and the wallet will then call `execute_transaction(txn, signatures)` with the same initial transaction and the signatures. + +The function will send the transactions and return status information of them to you. + +The below is an example psudo-Rust code of the usage of `GasAbstractionClient`: + +```rust +async fn main() { + let eoa = LocalSigner::random(); + let client = GasAbstractionClient::new(...); + let txn = Transaction { to: vitalik.eth, amount: 1 ETH }; + + let PreparedGasAbstraction { + hashes_to_sign, + fields + } = client.prepare_gas_abstraction(txn).await?; + + ask_user_for_approval(fields).await?; + + let signatures = hashes_to_sign.iter().map(|hash| account.sign(hash)).collect(); + + let receipt = client.execute_transaction(txn, Params { + signatures + }).await?; + + display_success(receipt) +} +``` + +```rust +impl GasAbstractionClient { + /// Just provide a project ID + async fn new(project_id: String) -> Self; + + /// Or you can make chain-specific clients if you want to do it manually + async fn new(chain_id: Caip10, rpc_url: Url, bundler_url: Url, paymaster_url: Url) -> Self; + + // Prepare and send gas-abstracted transactions + async fn bool prepare_gas_abstraction(Transaction transaction) -> PreparedGasAbstraction; + async fn bool execute_transaction(Transaction transaction, params: Params) -> B256; + + // Signature creation + async fn ..... COPY signature creation functions from current SDK + + // == Future APIs == + async fn send_user_operation(?) - ?; + async fn create_smart_session(?) -> ?; +} + +enum PreparedGasAbstraction { + hashes_to_sign: Vec, + fees: GasAbstractionFees, // similar to RouteUiFields -> fee and other UI info for user display +} + +enum Params { + /// EOA signatures by the transaction's sender of `hashes_to_sign` + signatures: Vec, +} +``` diff --git a/docs/walletkit/features/gas-abstraction.mdx b/docs/walletkit/features/gas-abstraction.mdx new file mode 100644 index 00000000..3f5a2a46 --- /dev/null +++ b/docs/walletkit/features/gas-abstraction.mdx @@ -0,0 +1,76 @@ +import Wrapper from '../../components/Home/Wrapper' + +import androidLogo from '../../../static/assets/home/androidLogo.png' +import iosLogo from '../../../static/assets/home/iosLogo.png' +import rnLogo from '../../../static/assets/home/rnLogo.png' +import flutterLogo from '../../../static/assets/home/flutterLogo.png' +import csharpLogo from '../../../static/assets/home/csharpLogo.png' +import javascriptLogo from '../../../static/assets/home/javascriptLogo.png' + +# Gas Abstraction for EOAs (experimental) + +Gas Abstraction enables existing EOA accounts to execute transactions without needing to have special tokens to pay for the transaction gas; for example ETH on Ethereum. This solution provides wallet developers with a toolkit to integrate gas abstraction using WalletKit. + +## How it works + +When your wallet receives a `wallet_sendTransaction` request, the wallet will automatically sponsor the transaction for the user using the Reown paymaster. Native gas tokens are not needed. + +This works by upgrading the EOA to a smart account that supports verifying paymasters and sending a sponsored User Operation. Specifically, a 7579 modular Safe smart account is deployed and delegated to in a 7702 transaction. The smart account has the same address as the EOA, and the EOA is the only signer on the account. + +## Get Started + + + +## FAQ + +### What are the available networks for Gas Abstraction? + +Gas Abstraction is available on any network where 4337 bundlers and paymasters are available. + +Click [here](/) to see what networks the Reown paymaster supports for seamless operation. + +### What types of paymasters are supported? + +Only verifying paymasters are currently supported (by default the Reown paymaster). ERC-20 paymasters are not yet supported. + +### What are the limitations? + +- Accounts that already have 7702 delegations will be rejected and are not supported. +- Because delegation cannot be removed (only changed), the account will need to indefinitely support EIP-1271 signature creation & validation. This is because apps assume if an account has code, that it is a smart account and it will use EIP-1271 to validate the signature. + +### What apps does this support? + +Any app that supports smart contract accounts. Specifically, EIP-1271 must now be used for signing. + +### Are more smart account features available or just gas abstraction? + +In the future more features will be supported such as: +- Sending user operations directly instead of transactions +- Smart sessions diff --git a/sidebars.js b/sidebars.js index 96c14bed..be27c5fa 100644 --- a/sidebars.js +++ b/sidebars.js @@ -305,6 +305,11 @@ module.exports = { label: 'Chain Abstraction', id: 'walletkit/features/chain-abstraction' }, + { + type: 'doc', + label: 'Gas Abstraction (experimental)', + id: 'walletkit/features/gas-abstraction' + }, { type: 'doc', label: 'Notifications', id: 'walletkit/features/notifications' }, { type: 'doc', label: 'Verify', id: 'walletkit/features/verify' } ]