Prerequisites
- Rust development environment
- Access to the
visualsign-parserworkspace - Access to the
visualsign-displayworkspace (for UI testing in step 6) - Understanding of the target blockchain’s transaction format
Step 1: Copy visualsign-unspecified as starting point
-
Navigate to the chain parsers directory:
-
Copy the unspecified template:
Replace
<your-chain>with your blockchain name (e.g.,visualsign-cosmos,visualsign-aptos) -
Update the new chain’s
Cargo.toml: -
Add your new chain to the workspace
Cargo.toml:
Step 2: Implement required traits
In your new chain’ssrc/lib.rs, implement the required traits:
Transaction trait
TheTransaction trait defines how to parse raw transaction data:
VisualSignConverter trait
TheVisualSignConverter trait handles the conversion to human-readable format:
Step 3: Write tests
Create comprehensive tests in your chain parser:Step 4: Add to registry
-
Add your chain to the proto definition in
proto/parser/parser.proto: -
Regenerate proto code:
-
Update
src/parser/app/src/chain_conversion.rs: -
Add your chain to the registry enum in
src/visualsign/src/registry.rs: -
Add your chain dependency to
src/parser/app/Cargo.toml: -
Register your converter in
src/parser/app/src/routes/parse.rs:
Step 5: Test with gRPC or parser CLI
You can test in two ways - either run the gRPC service for the app which requires building the whole stack, or call the parser_cli directly.Option A: gRPC parser
-
Build and run the parser service:
-
Test your implementation with grpcurl:
Option B: Parser CLI
Step 6: Test UI rendering
- Navigate to the
visualsign-displayrepository - Update the display service to handle your new chain type
- Test the end-to-end flow by sending transactions through the display interface
- Verify that your parsed transaction displays correctly in the UI with proper formatting and all relevant transaction details
Using existing Rust libraries
When a well-established Rust library exists for your blockchain, use it directly in your implementation:Advanced: FFI integration
If no suitable Rust library exists and you need to use an implementation in another language (like Go), you can use FFI. Thevisualsign-goethereum implementation serves as an example:
-
Create a
build.rsfile that compiles your foreign library: -
Create bindings for the foreign functions:
Testing your implementation
-
Run unit tests:
-
Run integration tests:
- Test with real transaction data using the gRPC interface
- Verify output formatting in the display UI
Related documentation
- Chain Module Architecture - Understanding the overall architecture
- Field Types - VisualSign JSON field reference
- Parser CLI - Command-line tool for development and testing
- Contribution Best Practices - Guidelines for contributors