Functions
constructor
function constructor(
uint64 nRoots,
address verifierAddr
) public
CAPE contract constructor method.
Parameters
Name | Type | Description |
---|---|---|
nRoots | uint64 | number of the most recent roots of the records merkle tree to be stored |
verifierAddr | address | address of the Plonk Verifier contract |
faucetSetupForTestnet
function faucetSetupForTestnet(
struct EdOnBN254.EdOnBN254Point faucetManagerAddress,
bytes32 faucetManagerEncKey
) external
Allocate native token faucet to a manager. For testnet only.
Parameters
Name | Type | Description |
---|---|---|
faucetManagerAddress | struct EdOnBN254.EdOnBN254Point | address of public key of faucet manager for CAP native token (testnet only!) |
faucetManagerEncKey | bytes32 | public key of faucet manager for CAP native token (testnet only!) |
_publish
function _publish(
uint256[] newNullifiers
) internal
Publish an array of nullifiers.
Requires all nullifiers to be unique and unpublished. A block creator must not submit notes with duplicate nullifiers.
Parameters
Name | Type | Description |
---|---|---|
newNullifiers | uint256[] | list of nullifiers to publish |
_publish
function _publish(
uint256 nullifier
) internal
Publish a nullifier if it hasn't been published before.
Reverts if the nullifier is already published.
Parameters
Name | Type | Description |
---|---|---|
nullifier | uint256 | nullifier to publish |
depositErc20
function depositErc20(
struct CAPE.RecordOpening ro,
address erc20Address
) external
Wraps ERC-20 tokens into a CAPE asset defined in the record opening.
Parameters
Name | Type | Description |
---|---|---|
ro | struct CAPE.RecordOpening | record opening that will be inserted in the records merkle tree once the deposit is validated |
erc20Address | address | address of the ERC-20 token corresponding to the deposit |
submitCapeBlockWithMemos
function submitCapeBlockWithMemos(
struct CAPE.CapeBlock newBlock,
bytes extraData
) external
Submit a new block with extra data to the CAPE contract.
Parameters
Name | Type | Description |
---|---|---|
newBlock | struct CAPE.CapeBlock | block to be processed by the CAPE contract |
extraData | bytes | data to be stored in calldata; this data is ignored by the contract function |
submitCapeBlock
function submitCapeBlock(
struct CAPE.CapeBlock newBlock
) public
Submit a new block to the CAPE contract.
Transactions are validated and the blockchain state is updated. Moreover BURN transactions trigger the unwrapping of cape asset records into erc20 tokens.
Parameters
Name | Type | Description |
---|---|---|
newBlock | struct CAPE.CapeBlock | block to be processed by the CAPE contract. |
_emitBlockEvent
function _emitBlockEvent(
) internal
This function only exists to avoid a stack too deep compilation error.
_handleWithdrawal
function _handleWithdrawal(
struct CAPE.BurnNote note
) internal
send the ERC-20 tokens equivalent to the asset records being burnt. Recall that the burned record opening is contained inside the note.
Parameters
Name | Type | Description |
---|---|---|
note | struct CAPE.BurnNote | note of type BURN |
_computeNumCommitments
function _computeNumCommitments(
) internal returns (uint256)
Compute an upper bound on the number of records to be inserted
_checkTransfer
function _checkTransfer(
struct CAPE.TransferNote note
) internal
Verify if a note is of type TRANSFER.
Parameters
Name | Type | Description |
---|---|---|
note | struct CAPE.TransferNote | note which could be of type TRANSFER or BURN |
_isExpired
function _isExpired(
struct CAPE.TransferNote note
) internal returns (bool)
Check if a note has expired.
Parameters
Name | Type | Description |
---|---|---|
note | struct CAPE.TransferNote | note for which we want to check its timestamp against the current block height |
_checkBurn
function _checkBurn(
struct CAPE.BurnNote note
) internal
Check if a burn note is well formed.
Parameters
Name | Type | Description |
---|---|---|
note | struct CAPE.BurnNote | note of type BURN |
_containsBurnPrefix
function _containsBurnPrefix(
bytes byteSeq
) internal returns (bool)
Checks if a sequence of bytes contains hardcoded prefix.
Parameters
Name | Type | Description |
---|---|---|
byteSeq | bytes | sequence of bytes |
_containsBurnRecord
function _containsBurnRecord(
struct CAPE.BurnNote note
) internal returns (bool)
Check if the burned record opening and the record commitment in position 1 are consistent.
Parameters
Name | Type | Description |
---|---|---|
note | struct CAPE.BurnNote | note of type BURN |
_deriveRecordCommitment
function _deriveRecordCommitment(
struct CAPE.RecordOpening ro
) internal returns (uint256 rc)
Compute the commitment of a record opening.
Parameters
Name | Type | Description |
---|---|---|
ro | struct CAPE.RecordOpening | record opening |
_prepareForProofVerification
function _prepareForProofVerification(
struct CAPE.TransferNote note
) internal returns (struct IPlonkVerifier.VerifyingKey vk, uint256[] publicInput, struct IPlonkVerifier.PlonkProof proof, bytes transcriptInitMsg)
An overloaded function (one for each note type) to prepare all inputs necessary for batch verification of the plonk proof.
Parameters
Name | Type | Description |
---|---|---|
note | struct CAPE.TransferNote | note of type TRANSFER |
_prepareForProofVerification
function _prepareForProofVerification(
struct CAPE.BurnNote note
) internal returns (struct IPlonkVerifier.VerifyingKey, uint256[], struct IPlonkVerifier.PlonkProof, bytes)
An overloaded function (one for each note type) to prepare all inputs necessary for batch verification of the plonk proof.
Parameters
Name | Type | Description |
---|---|---|
note | struct CAPE.BurnNote | note of type BURN |
_prepareForProofVerification
function _prepareForProofVerification(
struct CAPE.MintNote note
) internal returns (struct IPlonkVerifier.VerifyingKey vk, uint256[] publicInput, struct IPlonkVerifier.PlonkProof proof, bytes transcriptInitMsg)
An overloaded function (one for each note type) to prepare all inputs necessary for batch verification of the plonk proof.
Parameters
Name | Type | Description |
---|---|---|
note | struct CAPE.MintNote | note of type MINT |
_prepareForProofVerification
function _prepareForProofVerification(
struct CAPE.FreezeNote note
) internal returns (struct IPlonkVerifier.VerifyingKey vk, uint256[] publicInput, struct IPlonkVerifier.PlonkProof proof, bytes transcriptInitMsg)
An overloaded function (one for each note type) to prepare all inputs necessary for batch verification of the plonk proof.
Parameters
Name | Type | Description |
---|---|---|
note | struct CAPE.FreezeNote | note of type FREEZE |
getRootValue
function getRootValue(
) external returns (uint256)
Events
FaucetInitialized
event FaucetInitialized(
)
BlockCommitted
event BlockCommitted(
)
Erc20TokensDeposited
event Erc20TokensDeposited(
)