(Beta) Developer Toolkit
Beta toolkit is under development. Use only on testnet until V1 is released.
AutoGas Delegation Toolkit
This toolkit provides a framework for developers to build applications that interact with the AutoGas contract, enabling NFT owners to delegate their AutoGas NFTs to abstracted accounts and automatically receive ETH rewards. The design ensures security, restricts delegation to AutoGas NFTs only, and allows users to withdraw funds securely.Repository Structure
autogas-delegation-toolkit/
├── contracts/
│ ├── IDelegate.sol
│ ├── AutoGasToolkit.sol
│ └── AbstractedAccount.sol
├── docs/
│ └── README.md
├── widgets/
│ └── AutoConnect.js
└── package.jsoncontracts/: Solidity smart contracts.
docs/: Documentation (mirrored below).
widgets/: JavaScript widget for wallet connection and NFT delegation.
package.json: Manages dependencies and scripts.
Below is the complete AutoGas NFT Rewards Delegation Toolkit, including all code and documentation. The toolkit is designed to integrate with the AutoGas NFT contract at the hardcoded address 0xcc03a46173ee0e73cf464910f9eff372ca204821, which is the only method for connecting delegation. This ensures security and compatibility with the official AutoGas contract.
Contracts
IDelegate.sol
This interface defines the functions that the AutoGas contract calls on delegated accounts.solidity
AutoGasToolkit.sol
This contract manages the creation of abstracted accounts and NFT delegation, with the AutoGas contract address hardcoded.solidity
AbstractedAccount.sol
This contract handles delegated NFTs, receives ETH rewards, and supports ERC-4337 account abstraction.solidity
AutoConnect.js
This JavaScript widget simplifies wallet connection, abstracted account creation, and NFT delegation.javascript
Documentation (docs/README.md)
Install dependencies:
Contracts
IDelegate.sol
Interface for abstracted accounts to handle delegation and rewards.
onDelegated: Called when an NFT is delegated.
onRevoked: Called when delegation is revoked.
receiveReward: Receives ETH rewards from AutoGas.
AutoGasToolkit.sol
Manages abstracted account creation and NFT delegation, hardcoded to the official AutoGas contract.
createAbstractedAccount: Deploys a new abstracted account for the caller.
delegateToAbstractedAccount: Delegates an NFT to the specified abstracted account.
revokeDelegationFromAbstractedAccount: Revokes delegation of an NFT.
AbstractedAccount.sol
Handles delegated NFTs and ETH rewards, with ERC-4337 support.
receiveReward: Accumulates ETH rewards from AutoGas.
withdrawRewards: Allows the owner to withdraw accumulated rewards.
validateUserOp & executeUserOp: ERC-4337 functions for account abstraction.
Integration Guide for Developers
Deploy AutoGasToolkit:
Deploy with the ERC-4337 EntryPoint address as a constructor argument.
Create Abstracted Accounts:
Users call createAbstractedAccount to deploy their own abstracted account.
Delegate NFTs:
Users delegate NFTs to their abstracted account using delegateToAbstractedAccount.
Receive and Withdraw Rewards:
ETH rewards are automatically sent to the abstracted account by AutoGas.
Users withdraw rewards using withdrawRewards from their abstracted account.
How It Works
Delegation:
Users create an abstracted account and delegate their AutoGas NFT to it.
Delegation is restricted to the official AutoGas contract at 0xcc03a46173ee0e73cf464910f9eff372ca204821.
Reward Distribution:
The AutoGas contract sends ETH rewards to the abstracted account via receiveReward.
Rewards are tracked per token ID in the tokenRewards mapping.
Withdrawal:
Users call withdrawRewards on their abstracted account to transfer ETH to their wallet.
ERC-4337 Support:
Abstracted accounts support gasless transactions and other features via the EntryPoint.
Security Considerations
Hardcoded AutoGas Address: Ensures only the official AutoGas contract at 0xcc03a46173ee0e73cf464910f9eff372ca204821 is used for delegation.
Reentrancy Protection: withdrawRewards uses ReentrancyGuard to prevent reentrancy attacks.
Access Control: Only the owner can withdraw rewards; only AutoGas can call delegation/reward functions.
ERC-4337 Security: validateUserOp and executeUserOp are restricted to the EntryPoint.
License
MIT License - See LICENSE for details.
Last updated