Functions

constructor

  function constructor(
    uint64 nRoots,
    address verifierAddr
  ) public

CAPE contract constructor method.

Parameters

NameTypeDescription
nRootsuint64number of the most recent roots of the records merkle tree to be stored
verifierAddraddressaddress 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

NameTypeDescription
faucetManagerAddressstruct EdOnBN254.EdOnBN254Pointaddress of public key of faucet manager for CAP native token (testnet only!)
faucetManagerEncKeybytes32public 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

NameTypeDescription
newNullifiersuint256[]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

NameTypeDescription
nullifieruint256nullifier 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

NameTypeDescription
rostruct CAPE.RecordOpeningrecord opening that will be inserted in the records merkle tree once the deposit is validated
erc20Addressaddressaddress 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

NameTypeDescription
newBlockstruct CAPE.CapeBlockblock to be processed by the CAPE contract
extraDatabytesdata 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

NameTypeDescription
newBlockstruct CAPE.CapeBlockblock 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

NameTypeDescription
notestruct CAPE.BurnNotenote 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

NameTypeDescription
notestruct CAPE.TransferNotenote 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

NameTypeDescription
notestruct CAPE.TransferNotenote 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

NameTypeDescription
notestruct CAPE.BurnNotenote of type BURN

_containsBurnPrefix

  function _containsBurnPrefix(
    bytes byteSeq
  ) internal returns (bool)

Checks if a sequence of bytes contains hardcoded prefix.

Parameters

NameTypeDescription
byteSeqbytessequence 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

NameTypeDescription
notestruct CAPE.BurnNotenote of type BURN

_deriveRecordCommitment

  function _deriveRecordCommitment(
    struct CAPE.RecordOpening ro
  ) internal returns (uint256 rc)

Compute the commitment of a record opening.

Parameters

NameTypeDescription
rostruct CAPE.RecordOpeningrecord 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

NameTypeDescription
notestruct CAPE.TransferNotenote 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

NameTypeDescription
notestruct CAPE.BurnNotenote 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

NameTypeDescription
notestruct CAPE.MintNotenote 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

NameTypeDescription
notestruct CAPE.FreezeNotenote of type FREEZE

getRootValue

  function getRootValue(
  ) external returns (uint256)

Events

FaucetInitialized

  event FaucetInitialized(
  )

BlockCommitted

  event BlockCommitted(
  )

Erc20TokensDeposited

  event Erc20TokensDeposited(
  )