Skip to main content
This tutorial reads the ETH balance of Ethereum mainnet address 0xd8da6bf26964af9d7eed9e03e53415d37aa96045, then uses the ETH price in price.price.eth to calculate its USD value.

Before you begin

Sign in to the Chaintable console. If you don’t have a Space yet, click New Space on the Spaces page, enter an Id, and click Create space.
New Space dialog with the Id field and Create space button
Open your new or existing Space. This tutorial uses demo; replace it with your Space ID.

1. Create a Function

In Functions, click + in the upper right, enter wallet_eth_value, and click Save and open. Replace the default code with:
ChainState reads the wallet balance at the latest block, and TimeTable reads the ETH price. Divide the balance in wei by 10 ** 18 to get ETH.

2. Set test parameters

Click + in the parameter bar below the editor and add: Save the parameter and Function. Enter this value in the address input:
Press Enter to confirm the input, then click Run.

3. View the result

Return shows the balance, block, price and price timestamp, and calculated USD value.
wallet_eth_value returns ETH balance, price, price timestamp, and USD value
The balance in the screenshot is about 5.76818 ETH; your result will vary as the onchain balance changes. The USD value is estimated using the latest price record, whose timestamp is returned as price_time.

Optional: call from an external application

The saved Function ID is demo.wallet_eth_value. To call it from another application, pass the wallet address through OpenAPI. See Example request.