diff --git a/docs/contract/precompile_contracts.md b/docs/contract/precompile_contracts.md index 2c1ca1b9..8b56a2bd 100644 --- a/docs/contract/precompile_contracts.md +++ b/docs/contract/precompile_contracts.md @@ -314,3 +314,105 @@ contract CallCkbVm { ``` + +### CkbBlake2b + +| ADDRESS | MINIMUM GAS | INPUT | OUTPUT | +| --- | --- | --- | --- | +| 0x0000000000000000000000000000000000000106 | 60 | data | hash | + +Calculate the ckb-blake2b hash. + +#### Inputs + +
Click here to view ABI + +```solidity +struct Input { + byte[] data; +} +``` + +
+ +#### Output + +
Click here to view ABI + +```solidity +struct Output { + bytes32 hash; +} +``` +
+ +### CkbMbtVerify + +| ADDRESS | MINIMUM GAS | INPUT | OUTPUT | +| --- | --- | --- | --- | +| 0x0000000000000000000000000000000000000107 | 56000 | verify proof payload | bool | + +Verify the CKB merkle binary tree proof. + +#### Inputs + +
Click here to view ABI + +```solidity +struct VerifyProofPayload { + uint8 verifyType; + bytes32 transactionsRoot; + bytes32 witnessesRoot; + bytes32 rawTransactionsRoot; + Proof proof; +} + +struct Proof { + uint32[] indices; + bytes32[] lemmas; + bytes32[] leaves; +} +``` +If the verify_type is 0, the leaves should be in the rawTransactionsRoot, otherwise in the witnessesRoot. + +
+ +#### Output + +
Click here to view ABI + +```solidity +struct Output { + bool ret; +} +``` +
+ +#### Example + +
Click here to view example + +```solidity +contract VerifyCMBTRoot { + event VerifyCMBTRootEvent(bool); + event NotVerifyCMBTRootEvent(); + + int8 ret; + + function verifyCMBTRoot(VerifyProofPayload payload) public returns (bool) { + address get_cell_addr = address(0x0107); + (bool isSuccess, bytes memory res) = get_cell_addr.staticcall( + abi.encode(payload) + ); + + if (isSuccess) { + emit VerifyCMBTRootEvent(isSuccess); + } else { + emit NotVerifyCMBTRootEvent(); + } + return isSuccess; + } +} +``` + +
\ No newline at end of file