Skip to main content
In this guide, we’ll walk you through building a Web3 wallet auto top-up system using Kwala Workflows, a low-code, YAML-based automation platform for blockchain developers. With Kwala, you can connect on-chain events to automated smart contract executions without cron jobs, servers, or custom scripts. In this use case, you’ll learn how to automatically monitor wallet balances and top-up low balances in real time through smart contracts and event-driven workflows powered by Kwala.

Objective

Build a two-part workflow system that:
  • Continuously checks wallet balances and detects when a wallet’s native POL balance drops below a threshold of 0.1 POL.
  • Automatically transfers funds to top up the wallet whenever a low-balance event is emitted.
This setup enables self-sustaining wallets that stay funded without manual monitoring.

Step 1: Smart contract setup

We use two Solidity contracts:

1. PolNativeBalanceChecker.sol

This contract checks a wallet’s POL balance and emits a LowPolBalance event when the balance is below the predefined threshold. File name: PolChecker.sol
Deploy this contract on Polygon Amoy Testnet and copy the deployed contract address, for example: 0x85bc99d6207aD8284fb2bD0C5A4ebaA6F4B140e4.

2. AutoTopUp.sol

This contract performs the top-up of wallets that fall below the balance threshold. File name: AutoTopUp.sol
Deploy AutoTopUp and fund it with enough POL so it can perform top-ups.

Step 2: Setting up Kwala workflows

This automation uses two Kwala workflows that communicate via emitted events.

Workflow 1: BCPollingperMinute polling workflow

Purpose: Continuously monitor a wallet’s POL balance by calling checkAndWarn(). Trigger parameters:
  • Execute After: immediate
  • Repeat Every: 1m every minute
  • Expires In: 1759213800 timestamp
Action: Calls checkAndWarn(address user) on the deployed PolNativeBalanceChecker contract. If the wallet’s balance is below 0.1 POL, the contract emits LowPolBalance(address,uint256). YAML 1: Polling workflow
The polling workflow calls the checker every minute for the target wallet address, for example: 0x0F0C…f380f0.

Workflow 2: AutoTopUp1 auto top-up workflow

Purpose: Automatically top up wallets whenever a LowPolBalance event is emitted. Trigger parameters:
  • Trigger Source Contract: 0x85bc99d6207aD8284fb2bD0C5A4ebaA6F4B140e4
  • Trigger Chain ID: 80002 Polygon Amoy
  • Trigger Event Name: LowPolBalance(address,uint256)
  • Execute After: event
  • Repeat Every: event
When triggered, this workflow calls the AutoTopUp contract’s topUpIfLow() function to send funds. YAML 2: AutoTopUp workflow
The auto-top-up workflow listens for LowPolBalance events emitted by the checker contract and then calls the top-up action on the AutoTopUp contract.

Step 3: Deploy and test the workflows

  1. Save and compile both YAML workflows in the Kwala Dashboard.
  2. Deploy Workflow 1 (polling) and Workflow 2 (auto top-up).
  3. Wait until both workflows show Claimed.
  4. Fund the deployed AutoTopUp contract with sufficient POL.
When a monitored wallet’s balance drops below 0.1 POL:
  • Workflow 1 polling calls checkAndWarn() and the checker emits LowPolBalance.
  • Workflow 2 detects the event and calls topUpIfLow() on the AutoTopUp contract, which transfers 1 POL to the wallet.

Step 4: Monitor workflow execution

Use the Kwala Dashboard to inspect:
  • Workflow Logs: verify triggers and action calls.
  • Execution Status: confirm successful top-ups.
  • Retries and Failures: troubleshoot any missed or failed attempts.

Output

Once both workflows run successfully, the AutoTopUp contract transfers 1 POL to the wallet address whenever its balance goes below 0.1 POL, creating a self-regulating on-chain wallet. If you add Telegram or other notifications to the workflows, you can surface messages like:
“AutoTopUp executed — wallet 0x0F0C…F380f0 rebalanced successfully.”

Conclusion

With thr two YAML workflows, we created an auto top-up wallet system using Kwala Workflows without backend scripts, centralized orchestration, or manual intervention. This use case highlights how Kwala bridges event-driven Web3 logic with automated smart contract execution, enabling developers to build real-world, autonomous blockchain systems quickly and reliably.

Next steps

Monitor Your Workflows

Learn how to track and analyze your workflow executions in real-time

Best Practices

Discover tips and patterns for building robust Web3 automations