This directory contains examples demonstrating how to use the TrueBlocks core SDK for various blockchain data tasks.
These examples showcase different features and capabilities of TrueBlocks, helping developers understand how to:
- Query and analyze blockchain data
- Work with addresses, transactions, and blocks
- Efficiently index and retrieve on-chain information
- Implement common blockchain data patterns
- balanceChart - Generate charts showing ETH balance changes over time
- cancelContext - Demonstrate context cancellation for long-running operations
- chainList - List and display information about supported chains
- checkNodes - Verify and check node connectivity and status
- comparison - Compare data between different sources or time periods
- findFirst - Find the first occurrence of specific blockchain events
- four_bytes - Work with four-byte function signatures and method IDs
- keystore - Manage and work with Ethereum keystore files
- monitorService - Monitor blockchain addresses and events
- nameManager - Work with ENS names and address resolution
- simple - Basic example showing fundamental SDK usage
- withStreaming - Demonstrate streaming data capabilities
Most examples can be run with:
cd example-directory
go run .
When creating examples to test new features on a local branch:
-
Create from template:
cd examples chifra init --example your-example-name
-
Add local replace directives to the generated
go.mod
:replace github.com/TrueBlocks/trueblocks-sdk/v5 => ../sdk replace github.com/TrueBlocks/trueblocks-core/src/apps/chifra => ../src/apps/chifra
-
Add to .gitignore to prevent breaking CI:
echo "your-example-name/" >> .gitignore
-
Update go.work:
cd .. ./scripts/go-work-sync.sh
When your example is ready for production:
- Remove replace directives from
go.mod
- Remove from .gitignore
- Run go-work-sync.sh to update dependencies to published versions
- Test the example works with published dependencies
- Commit and submit PR
To run these examples, you'll need:
- TrueBlocks core installed
- Access to an Ethereum node (local or remote)
- Any additional dependencies specified in the example's README
- Development Examples: Examples with
replace
directives ingo.mod
should be in.gitignore
- CI/CD: Examples committed to the repo must use published dependencies only
- go.work: Always run
./scripts/go-work-sync.sh
after adding new examples - Testing: Test examples work with both local and published dependencies
For more detailed information, visit the TrueBlocks documentation.
We welcome contributions! When adding new examples:
- Follow the development process above
- Ensure examples work with published dependencies
- Include a README.md explaining the example's purpose
- Add appropriate error handling and comments