Rewrites the broken chain_sync.py stub into a working on-chain settlement module for credit issuance and retirement.
chain_sync.py
sync_credits_to_chain()
issue()
retire_onchain()
retire()
verify_chain_balance()
balanceOf
reconcile_all()
batch_manager.issue_batch()
carbon_credits.review_retirement()
chain-sync
contracts/abis/KokonutCreditToken.json
All on-chain calls gated by CREDIT_ONCHAIN_SYNC_ENABLED env var (default false). No behavioral change for existing deployments.
CREDIT_ONCHAIN_SYNC_ENABLED
false
15 mocked web3 tests covering minting, retirement, balance verification, reconciliation, and token ID computation.
Summary
Rewrites the broken
chain_sync.pystub into a working on-chain settlement module for credit issuance and retirement.Changes
sync_credits_to_chain(): correct ERC-1155 ABI, keccak256 tokenId derivation matching Solidity contract, actual web3issue()transactionsretire_onchain(): callsretire()on ERC-1155 contract for confirmed retirementsverify_chain_balance(): uses ERC-1155balanceOf(was incorrectly using EAS contract)reconcile_all(): real account addresses, correct token ID derivationbatch_manager.issue_batch()andcarbon_credits.review_retirement()chain-syncwith sync, retire-onchain, verify, and reconcile operationscontracts/abis/KokonutCreditToken.jsonSafety
All on-chain calls gated by
CREDIT_ONCHAIN_SYNC_ENABLEDenv var (defaultfalse). No behavioral change for existing deployments.Tests
15 mocked web3 tests covering minting, retirement, balance verification, reconciliation, and token ID computation.