diff --git a/RootVerifier.sol b/RootVerifier.sol new file mode 100644 index 0000000..87dc8d8 --- /dev/null +++ b/RootVerifier.sol @@ -0,0 +1,16 @@ +pragma solidity ^0.8.0; + +contract StateRootVerifier { + bytes32 private currentRoot; + + function verifyAndUpdate(bytes32 oldRoot, bytes32 newRoot) external { + require(oldRoot == currentRoot, "Invalid old state root"); + + // 更新链上状态树根 + currentRoot = newRoot; + } + + function getCurrentRoot() external view returns (bytes32) { + return currentRoot; + } +}