Postchain EIF is a multi-module framework enabling Chromia-Ethereum interoperability. It provides bidirectional communication between Postchain (Chromia) and EVM-compatible blockchains through event-driven cross-chain messaging and cryptographic proof verification.
postchain-eif/
├── postchain-eif-contracts/ # Solidity smart contracts (EVM side)
├── postchain-eif-core/ # Kotlin implementation (EifGtxModule)
└── postchain-eif-rell/ # Rell library (Postchain side)
Solidity smart contracts for the EVM side of the bridge.
- Language: Solidity 0.8.24
- Build: Hardhat with TypeScript
- Node: 24.x with Yarn 4.10.1
- Contracts: OpenZeppelin v5.1.0 (upgradeable)
- Types: TypeChain for type-safe interactions
cd postchain-eif-contracts
./scripts/build.sh
./scripts/test.shMain Bridge Contracts:
TokenBridge.sol- Upgradeable ERC-20 bridge with deposit, pending withdrawal supportTokenBridgeWithSnapshotWithdraw.sol- TokenBridge extension with snapshot-based withdrawal support for mass exitChromiaTokenBridge.sol- Upgradeable native CHR token bridge variant that mints/burns CHR tokens instead of holding themcrc2/NFTBridge.sol- Upgradeable bridge for ERC-721/ERC-1155 NFTs with pending withdrawal support
Validator Contracts:
Validator.sol- Simple validator with owner-managed validator list and BFT signature verificationvalidatorupdate/BaseManagedValidator.sol- Abstract base for validators with Postchain-verified signer updatesvalidatorupdate/DirectoryChainValidator.sol- Validator for directory chain with self-verified signer updatesvalidatorupdate/ManagedValidator.sol- Validator for dapp chains with directory-chain-verified signer updatesvalidatorupdate/ValidatorUpdateUtils.sol- Decoder utilities for validator update and proof data structures
Core Libraries:
Postchain.sol- Library for block header parsing, event verification, and Merkle proof validationData.sol- Data structures for Merkle proofs (ExtraProofData, Proof)
Utils:
utils/cryptography/Hash.sol- Keccak256/SHA256 hashing for Merkle trees and GTV encodingutils/cryptography/MerkleProof.sol- Merkle proof verification using keccak256 and SHA256utils/cryptography/ECDSA.sol- ECDSA signature recovery with malleability protectionutils/TwoWeekDelay.sol- Abstract contract enforcing two-week delay on sensitive actions
Other:
TokenMinter.sol- Rate-limited mint/burn controller for CHR token with two-week delayRecoveryContract.sol- Standalone snapshot-based token recovery for mass exitanchoring/Anchoring.sol- Anchors Chromia blockchain blocks to EVM with sequential height validation
Token Contracts (Legacy/Reference):
token/ChromiaToken.sol- Original CHR token (Ethereum mainnet, Solidity 0.5)token/ChromiaTokenBsc.sol- CHR token for BSC (Solidity 0.6)
Upgrade/Test:
upgrade-v4-offset/TokenBridgeV4.sol- TokenBridge with additional initializer for withdrawTimeOffset updatetest/*- Test helpers and mock contracts
Ethereum, BSC, Base, Sepolia, and other EVM-compatible chains (see hardhat.config.ts)
Test Files:
bridge.test.ts- TokenBridge deposit, pending withdrawal, withdrawal completion, mass exit, snapshot withdrawalchromiabridge.test.ts- ChromiaTokenBridge with mint/burn flow and daily limitsmanagedvalidator.test.ts- ManagedValidator and DirectoryChainValidator signer update verificationtokenminter.test.ts- TokenMinter daily limits, two-week delay, mint role transferutility.test.ts- Hash functions, Merkle proof verification, GTV encodingerc20.test.ts- Basic ERC-20 token transfer and balance tests
Test Utils:
utils.ts- GTV hashing helpers, hex conversions, discriminator calculationblock.utils.ts- Withdraw event building, Merkle root calculation, proof encodingblockbuilder.utils.ts- Block header builder for test scenariosblockheader.const.utils.ts- Constant blockchain RIDs and hashes for tests
Scripts are Hardhat tasks run via yarn <script-name> or npx hardhat <task-name>.
Build Scripts:
clean- Remove coverage directory, coverage.json, and abi directorycompile- Compile Solidity contractstest- Run test suitetypechain- Generate TypeScript typings for contractscoverage- Run test coverage analysis
Validator Deployment:
deploy:directoryValidator- Deploy DirectoryChainValidator contractdeploy:validator- Deploy Validator or ManagedValidator contractdeploy:anchoring- Deploy ManagedValidator and Anchoring contract for a blockchain RIDinspect:validator- Inspect deployed Validator contractinspect:managedValidator- Inspect deployed ManagedValidator contractinspect:directoryValidator- Inspect deployed DirectoryChainValidator contract
Bridge Deployment:
deploy- Deploy TokenBridge for EVM-native tokensdeploy:native- Deploy ChromiaTokenBridge for Chromia-native tokens (mint/burn)deploy:snapshots- Deploy TokenBridgeWithSnapshotWithdraw for mass exit supportimport:bridge- Import existing TokenBridge contractprepare:bridge- Prepare TokenBridge upgradeupgrade:bridge- Upgrade TokenBridge contractupgrade:bridge:v4-offset- Upgrade TokenBridgeV3 to V4 with new withdraw time offsetupgrade:bridge:v4-offset:prepare- Prepare V4 offset upgraderead:bridge-offset- Read current bridge withdraw time offsetsetBlockchainRid:bridge- Set blockchain RID for TokenBridgefinalizeBlockchainRid:bridge- Finalize blockchain RID (one-time operation)allowToken:bridge- Configure token allowance on TokenBridgeapproveToken:bridge- Approve token spending by TokenBridgeinspect:bridge- Inspect deployed TokenBridgeinspect:chromiabridge- Inspect deployed ChromiaTokenBridgepause:bridge/unpause:bridge- Pause/unpause bridge operations
NFT Bridge:
deploy:nftbridge- Deploy NFTBridge contractinspect:nftbridge- Inspect deployed NFTBridgesetBlockchainRid:nftbridge- Set blockchain RID for NFTBridgefinalizeBlockchainRid:nftbridge- Finalize blockchain RIDallowToken:nftbridge- Configure NFT contract allowance
Recovery Contract:
deploy:recovery- Deploy RecoveryContract for mass exitsetBlockchainRid:recovery- Set blockchain RID for RecoveryContractfinalizeBlockchainRid:recovery- Finalize blockchain RID
Transaction Resubmission:
transaction:resubmitSignerUpdate- Resubmit failed signer update transactiontransaction:resubmitAnchoring- Resubmit failed anchoring transaction
Token Deployment:
deploy:alice- Deploy ALICE test tokendeploy:chromiatokenbsc- Deploy Chromia token on BSC
Kotlin implementation providing EifGtxModule.
- Language: Kotlin 2.0.0 (Java 21 target)
- Build: Maven 3.8+
- Framework: Postchain 3.47.7
- Ethereum: Web3j 4.13.0
- HTTP: OkHttp 4.9.3
- Crypto: BouncyCastle
- Database: JOOQ
- CLI: Clikt
# Note: Requires contracts to be built first
mvn clean package
# Run unit tests
mvn test
# Run integration tests (requires Docker)
mvn verify -Pintegration-testssrc/main/kotlin/net/postchain/eif/
├── EifSpecialTxExtension.kt # Main event processing
├── EvmBlockOp.kt # EVM block operation model
├── EventFetcher.kt # Event fetching interface
├── config/ # Configuration classes
├── transaction/ # TX submission logic
│ ├── TransactionSubmitter.kt
│ ├── gas/ # EIP-1559 fee estimation
│ └── anchoring/ # Postchain anchoring
└── web3j/ # Web3j handlers
EifSpecialTxExtension: Manages special transactions for EVM eventsEifBlockBuilderExtension: Integrates EVM events into Postchain block buildingTransactionSubmitterSpecialTxExtension: Handles EVM transaction submissionEvmAnchoringSpecialTxExtension: Manages Postchain anchoring to EVMEvmSignerUpdateSpecialTxExtension: Handles validator updates across chains
EifEventReceiverConfig: Event receiver configurationEvmTransactionSubmitterConfig: TX submission configurationEifEvmBlockchainConfig: EVM connection configurationEifContainerConfigProvider: Container-based configuration
Rell modules for Chromia-side EIF integration.
- Language: Rell 0.14.5
- Plugin: Rell Maven Plugin 0.16.4
- Dependencies: FT4, ICCF, ICMF, CRC2
EIF provides the following libraries for Chromia dapps:
eif- Common utilities, messaging infrastructure, and event handling primitiveseif_event_receiver- Receives and stores EVM blocks/events, forwards them via ICMFhbridge- ERC-20 token bridge: deposits, withdrawals, account linking, snapshotshbridge_crc2- NFT token bridge (ERC-721/1155 to CRC2)hbridge_admin- Bridge administration: blacklist/whitelist management, fund seizure
# Install Rell dependencies
cd postchain-eif-rell/rell
chr install
# Build the project
chr build --hide-lib-warnings
# Build with specific configuration
chr build --hide-lib-warnings --settings <config-file>The tests can be found in the postchain-eif-rell/rell/src/tests directory.
# Run Rell tests
chr test --hide-lib-warnings
# Run tests with detailed reporting
chr test --test-report --hide-lib-warnings
# Run tests of specific module
chr test -m <module-name> --hide-lib-warnings
# Run tests for specific blockchain
chr test -bc <blockchain-name> --hide-lib-warnings
# Run specific test
chr test -t <test-name> --hide-lib-warnings
# Run Rell tests of specific module with specific test names
chr test --hide-lib-warnings -m <module-name> --tests <csv-list-of-test-names>
# Run Rell test set specified by pattern (e.g. *withdraw*)
chr test --hide-lib-warnings -m <module-name> --tests <test-pattern>lib/eif/ - Common utilities and messaging infrastructure
common/- Event counter for serial numberingmessaging/- EVM block message structs and event data typesevent_connector/- ICMF message receiver for EVM block eventsdynamic_config_common/- Shared dynamic configuration for event receiver chainsutils/- Utility functions
lib/eif_event_receiver/ - Event receiver chain integration
model/- EVM block and event entity definitionsqueries/- Queries for EVM blocks and eventspause/- Pause/unpause functionalitydynamic_config/- Dynamic configuration managementdynamic_icmf_config/- ICMF message receiver for dynamic configuration
lib/hbridge/ - ERC-20 token bridge
core/- Account linking, bridge contracts, state snapshotserc20/- ERC-20 asset registration and queriesdeposits.rell- Deposit processing from EVMwithdrawals.rell- Withdrawal processing to EVMoperations.rell- Bridge operationsqueries/- Common queries for ERC-20 token bridgedeposit_queries.rell- Deposit querieswithdrawal_queries.rell- Withdrawal queriesevm_events.rell- EVM event handlerseif_events.rell- EIF event handling
lib/hbridge_crc2/ - NFT token bridge (ERC-721/1155 to CRC2)
evm/- EVM account linking, bridge contracts, NFT collection registrationdeposits.rell- NFT deposit processing from EVMwithdrawals.rell- NFT withdrawal processing to EVMoperations.rell- Bridge operationsdeposit_queries.rell- Deposit querieswithdrawal_queries.rell- Withdrawal queriesevm_events.rell- EVM event handlerseif_events.rell- EIF event handling
lib/hbridge_admin/ - Bridge administration
access_list_control/- Blacklist/whitelist management
transaction_submitter/ - Rell module for submitting transactions to EVM
anchoring/- System Anchoring chain block anchoring to EVM with interval controlsigner_update/- Validator set updates on EVM contracts with Merkle proofsmessaging/- ICMF topics and message structs for cross-chain TX submissionmodel.rell-evm_submit_transactionentity, status enum (QUEUED/TAKEN/PENDING/SUCCESS/FAILURE)module.rell- Transaction timeout handlers, ICMF message receiversbridge_mapping.rell- Blockchain-to-bridge contract mappings via ICMFexternal_api.rell- Queries for transaction status, receipts, and bridge listingssystem_chains.rell- Directory chain and System Anchoring chain configuration
- EventFetcher: Periodically fetches events from EVM blockchains
- EventProcessor: Validates and processes EVM events
- EvmBlockOp: Represents EVM block data operation with EVM events
- Queue-based system with concurrent transaction tracking
- EIP-1559 fee estimation
- Transaction status polling and cancellation support
- Health checks and wallet balance monitoring
QUEUED → TAKEN → PENDING → VERIFIED → SUCCESS/FAILURE
- EVM emits event
- EventFetcher polls for new events
- Events are batched into EvmBlockOp
- Merkle proofs generated for verification
- Postchain processes events via special transactions
- State synchronized across chains
EvmMerkleProofBuilder: Constructs Merkle proofs for cross-chain validationProofTreeParser: Parses proof trees from EVM events
EIF supports pause/unpause for maintenance and security. Event processing respects pause state.
GitLab CI pipeline stages:
- contracts: Compile Solidity, run tests, generate TypeChain
- build: Maven build, Web3j codegen, Rell compilation
- integration-tests: Run TestContainer-based tests
- dependency-check: OWASP vulnerability scanning
- release: Deploy to GitLab Maven registry