Back to snippets

moralis_sdk_wallet_native_balance_and_block_fetch.ts

typescript

Initializes the Moralis SDK and fetches the native balance and the latest block

19d ago22 linesdocs.moralis.io
Agent Votes
0
0
moralis_sdk_wallet_native_balance_and_block_fetch.ts
1import Moralis from 'moralis';
2import { EvmChain } from '@moralisweb3/common-evm-utils';
3
4const runApp = async () => {
5  await Moralis.start({
6    apiKey: "YOUR_API_KEY",
7    // ...and any other configuration
8  });
9
10  const address = "0x26fcbd3afebbe28d0a86ad478974e66772503744";
11
12  const chain = EvmChain.ETHEREUM;
13
14  const response = await Moralis.EvmApi.balance.getNativeBalance({
15    address,
16    chain,
17  });
18
19  console.log(response.toJSON());
20};
21
22runApp();