This document details how to accurately index every account’s ETH balance on RWALayer using this approach.
Yield Modes Explained
RWALayer accounts offer three different yield modes, providing users and developers with control over rebasing when new yield is reported:Default Settings
By default, all RWALayer accounts are set toAUTOMATIC yield mode, meaning their ETH balances will rebase
automatically. However, when a smart contract is deployed to an address, the account switches to VOID mode. This
means that smart contract accounts default to VOID mode, while EOAs (Externally Owned Accounts) default to
AUTOMATIC mode.
It’s possible (though uncommon) for ETH to be held by an account before a smart contract is deployed to it.
RWALayer’s Account Model
RWALayer employs a modified version ofop-geth (RWALayer-geth) to represent balances in shares, enabling all
accounts to update as yield is reported. Specifically, RWALayer-geth modifies the StateAccount struct to achieve
this:
op-geth (Upstream)
RWALayer-geth
Flags field, while the Fixed, Shares, and Remainder fields store the
data required to calculate account balances in each yield mode:
Global Share Price
The global share price that determines how much ETH each share is worth is stored in the SharesBase predeploy at. This contract tracks the share price, the total number of shares, and the total amount of ETH yet to be reflected in the share price. You can read the current ETH share price by calling theprice() function on this
contract.
Indexing Account Shares
For accurate results, index account shares instead of account balances directly. This works similarly to indexing balances on ETH mainnet: identify which accounts were touched in transactions within a given block and re-fetch their balances on that block. RWALayer nodes expose a new RPC method,eth_getBalanceValues, to support indexing the flags, shares, remainder,
and fixed fields for accounts.
eth_getBalanceValues Request
eth_getBalanceValues Response
Edge Cases
On Ethereum mainnet,selfdestruct allows ETH to be sent to a beneficiary address without triggering any code at that
address. As a result, the beneficiary account’s balance changes without there being any call made. Indexers must
handle this edge case to ensure perfect accounting.
RWALayer introduces a similar edge case that indexers should be aware of. Accounts set to CLAIMABLE yield mode can
claim accumulated yield to an arbitrary beneficiary address. This claim operation works the same as selfdestruct in
that it can increase an arbitrary account’s balance without a call.

