BLOG — Use cases

348 days ago

Secure Your .ETH Forever: Automate Your ENS Renewal with Alchemix & Gelato

Every Ethereum user knows the value of an Ethereum Name Service (ENS) domain. These "human-readable" addresses (like "yourname.eth") replace cumbersome hexadecimal Ethereum addresses, making transactions more straightforward. However, maintaining ownership of these domains requires regular renewals, a task that's easy to overlook.

Forgetting to renew your ENS can result in losing your personalized address, leading to potential confusion and misdirected transactions. But there's no need to worry. We've got a solution in place: the Self-Repaying ENS (SRENS) service, thanks to wary for building this tool as part of the hackathon. SRENS automates the process of ENS domain renewals, effectively removing the risk of ever losing your unique .eth address.

This unique service is a collaboration between Alchemix and Gelato. Alchemix allows users to create self-repaying loans, turning their ETH into alETH to cover renewal fees. Meanwhile, Gelato automates the renewal process, ensuring ENS domains are consistently updated.

How Does the Self-Repaying ENS Work?

The SRENS leverages the unique capabilities of four distinct protocols: Gelato Automation, Alchemix, Curve, and the Ethereum Name System (ENS).


Alchemix is a future-yield-backed synthetic asset platform that allows users to get an advance on their future yield via self-repaying loans. In the context of SRENS, Alchemix users utilize their deposited ETH to create alETH, a yield-bearing version of ETH, to cover the ENS renewal fees.


To facilitate the conversion of alETH to ETH (which is necessary for ENS renewal fees), SRENS uses Curve, a stablecoin swap protocol on Ethereum. This ensures the most efficient conversion rate, minimizing the cost of renewal.

Ethereum Name System (ENS)

The ENS allows users to create human-readable addresses on Ethereum. However, these addresses need to be renewed annually, which is the problem SRENS aims to solve.

Gelato Automation

Here's where the magic of automation comes into play. Gelato automates the renewal process, ensuring that the ENS domains are renewed timely without any manual intervention from the user.

How To Use It

  1. Deposit funds in Alchemix: Deposit sufficient funds into Alchemix's alETH contract. Ensure that the amount is enough to cover the renewal fees for your ENS name.

  2. Visit the website and search for any ENS address you want to renew, and click the toggle switch for each ENS to which you want to auto-renew. For the contract to do its thing, click the big green "Approve" button to give the SRENS contract the ability to mint alETH from your Alchemix position on your behalf.

  3. After the approval from step 3 is confirmed, click the big green "Subscribe" button to enable SRENS to Auto-renew your ENS so that your name never expires.

The Role of Gelato in SERENS

Integrating Gelato into the SRENS system offers a solution for automating ENS renewals. Users would stake their alETH in the SRENS contract as collateral for the renewal fee. When the ENS name is about to expire, a Gelato 'bot' checks the condition (whether the ENS name is due for renewal). If true, this triggers a function that renews the ENS name using the collateralized alETH.

Let's delve into some key functions:

  1. To start the automation process, a user must allow the SelfRepayingENS contract to mint sufficient alETH debt to cover multiple renewals. This is done by calling alchemistV2.approveMint().

  2. The user then subscribes to the SRENS service for a name by calling srens.subscribe(<name>). They can also use the multicall feature to subscribe or unsubscribe for multiple names. Subscribing for the first time creates a Gelato task that regularly checks if your names should be renewed by calling srens.checker(). This is stored internally in a mapping. The subscribe() function initiates a Gelato task to monitor the user's ENS name expiration:

if (_taskIds[msg.sender] == 0) {
    _taskIds[msg.sender] =
        gelatoOps.createTask(address(this), abi.encode(this.renew.selector), _getModuleData(msg.sender), ETH);

Gelato uses the checker() function to decide when to execute the renewal task:

function checker(address subscriber) external view returns (bool canExec, bytes memory execPayload) {
    return highestLimit == 0
        ? (false, bytes("no names to renew"))
        : (true, abi.encodeCall(this.renew, (mostExpensiveNameToRenew, subscriber)));
  1. The Gelato task periodically queries this function. If it returns true for a name, Gelato instructs SRENS to renew it by calling srens.renew(). During the renewal process, SRENS mints enough alETH debt to pay for the renewal and Gelato fees in ETH by calling SelfRepayingETH.borrowSelfRepayingETHFrom(<your address>, <amount>). Afterward, it calls ETHRegistrarController.renew() to renew the ENS name.
function renew(string calldata name, address subscriber) external payable {
    // Borrow `neededETH` amount of ETH from `subscriber` Alchemix account.
    _borrowSelfRepayingETHFrom(subscriber, neededETH);

    // Renew `name` for its expiry data + `renewalDuration` first.
    controller.renew{value: namePrice}(name, renewalDuration);

    // Pay the Gelato executor with all the ETH left.
    (bool success,) ={value: address(this).balance}("");
    if (!success) revert FailedTransfer();
  1. If the user wants to unsubscribe from the Self Repaying ENS renewal service for a name, they can do so by calling srens.unsubscribe(<name>).
function unsubscribe(string memory name) external {
 // Not canceling `msg.sender`'s Gelato task make the last unsubscribe and following subscribe cheaper.

// Remove `name` from `subscriber`'s names to renew.
        bool removed = _subscribedNames[msg.sender].remove(name);
        // Revert if `name` was not part of `subscriber`'s names to renew.
        if (!removed) {
            revert IllegalArgument();

        emit Unsubscribe(msg.sender, name, name);


In conclusion, the Self-Repaying ENS service ingeniously harnesses the strengths of Alchemix, Gelato, Curve, and the Ethereum Name System to simplify and automate the process of maintaining ownership of ENS domains.

About Gelato

Get ready to witness a new era of web3 as Gelato, relied upon by over 400 web3 projects, powers the execution of millions of transactions in DeFi, NFT, and Gaming.

Gelato currently offers four services:

  • Web3 Functions: Connect your smart contracts to off-chain data & computation by running decentralized cloud functions.

  • Automate: Automate your smart contracts by executing transactions automatically in a reliable, developer-friendly & decentralized manner

  • Relay: Give your users access to reliable, robust, and scalable gasless transactions via a simple-to-use API

  • Gasless Wallet: A powerful SDK that enables developers to provide a world-class UX by combining Gelato Relay + Safe's Smart Contract Wallet, enabling Account Abstraction

Witness the ongoing journey towards a decentralized future led by Gelato!