Skip to content

Commit

Permalink
adding examples
Browse files Browse the repository at this point in the history
  • Loading branch information
strykerin committed Feb 11, 2025
1 parent fdb9398 commit 5516457
Show file tree
Hide file tree
Showing 4 changed files with 1,219 additions and 5 deletions.
27 changes: 27 additions & 0 deletions examples/fetch-blocks/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Import Push Chain SDK
import { CONSTANTS, PushChain } from '@pushchain/devnet';

// Initialize the Push Chain SDK
const pushChain = await PushChain.initialize();

// Fetch block by hash
const blockByHash = await pushChain.block.get(
'28ca25bb8a0b59b76612bcef411984d60f28d0468676fc755ed8f946433d0c64'
);

console.log(blockByHash);

// Fetch the latest 20 blocks
const latestBlocks = await pushChain.block.get('*', {
limit: 20,
});

console.log(latestBlocks);

// Fetch blocks by dates - yesterday
const blockByData = await pushChain.block.get('*', {
startTime: Math.floor(Date.now() - 24 * 60 * 60 * 1000),
order: 'ASC',
});

console.log(blockByData);
Loading

0 comments on commit 5516457

Please sign in to comment.