File size: 891 Bytes
2156c54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Network, Alchemy, AssetTransfersCategory } from 'alchemy-sdk';

const settings = {
  apiKey: `${process.env.AUTH_ALCHEMY_API_KEY || ""}`,
  network: Network.ETH_MAINNET,
};

const alchemy = new Alchemy(settings);

// get the latest block
const latestBlock = alchemy.core.getBlock("latest").then(console.log);

// get all the sent transactions from given address
const sentTransactions = alchemy.core.getAssetTransfers({
  fromBlock: "0x0",
  fromAddress: "0x994b342dd87fc825f66e51ffa3ef71ad818b6893",
  category: [
    // ERC721 transfers.
    AssetTransfersCategory.ERC721,

    // Top level ETH transactions that occur where the `fromAddress` is an
    // external user-created address. External addresses have private keys and are
    // accessed by users.
    AssetTransfersCategory.EXTERNAL,

    // ERC20 transfers
    AssetTransfersCategory.ERC20
   ],
}).then(console.log);