New features

Volition

Your users can now choose between off-chain data availability, known as Validium, and on-chain data availability.

StarkEx now provides two vault trees: one for on-chain data, and one for off-chain data.

The valid vault ranges are: [0, 231] for Validium vaults (off-chain) [263, 263+231] for the ZK-Rollup vaults (on-chain)

  • The vault size results in each signature having 63 bits allocated for vaults.

  • The StarkEx contract supports both vault id ranges. When depositing to a rollup vault, the 63rd bit of vaultId must be on. The roots of both vault trees are updated when UpdateState is called. The updated balances of rollup vaults are also emitted on-chain as calldata.

  • An escape hatch is checked against the tree in which the escaped vault is located.

Transaction bundling

StarkEx now supports a new type of transaction: A bundle set of transactions. With a transaction bundle, you can send StarkEx a list of transactions, where all transactions in the list are guaranteed to go into the same batch if possible, and if not possible, the system prompts for an alternative transaction. If any transaction inside the transaction bundle is invalid, you need to send an alternative transaction bundle.

A transaction bundle is useful for trading multiple asset types in one operation. For example, you can use transaction bundling to sell a set of NFTs as one package.

ERC-1155 token support

StarkEx now fully supports existing ERC-1155 tokens for both L1 and L2 vaults. Minting ERC-1155 tokens is not supported.

  • Each ERC-1155 token contract should be registered once, given assetInfo, which includes a selector and contract address, and a quantum. The same quantum applies to all different assets that belong to that asset type.

  • If different quantums are required for different assets within the same ERC-1155 contract, the same contract can be registered once per quantum. Note that each such registration results in a different asset type. The same tokenIds with different assetTypes result in different assetIds.

  • ERC1155_SELECTOR = bytes4(keccak256("ERC1155Token(address,uint256)")) (0x3348691d)

  • ERC-1155 tokens are deposited and withdrawn similarly to NFTs, including assetType and tokenId, but also including a quantizedAmount argument.

  • tokenId is the internal token id within the ERC-1155 contract.

  • assetId is a unique StarkEx identifier calculated as follows: uint256(keccak256(abi.encodePacked("NON_MINTABLE:", assetType, tokenId))) & MASK_250

    === New L2 vault functions

  • Deposit for both ERC-721 and ERC-1155, recommended. For ERC-721, quantizedAmount must equal one:

      function depositWithTokenId(
          uint256 starkKey,
          uint256 assetType,
          uint256 tokenId,
          uint256 vaultId,
          uint256 quantizedAmount
      )
  • A wrapper for depositWithTokenId that supports only ERC-1155 tokens:

      function depositERC1155(
          uint256 starkKey,
          uint256 assetType,
          uint256 tokenId,
          uint256 vaultId,
          uint256 quantizedAmount
      )
  • To reclaim a cancelled deposit.

      function depositWithTokenIdReclaim(
          uint256 starkKey,
          uint256 assetType,
          uint256 tokenId,
          uint256 vaultId
      )
  • Withdrawal function that supports both ERC-721 and ERC-1155

      function withdrawWithTokenId(
          uint256 ownerKey,
          uint256 assetType,
          uint256 tokenId
      )
  • Return the StarkEx asset id of a specific ERC-721 or ERC-1155 token. You can use this function to cancel a deposit, check pending on-chain balances, and so forth. function calculateAssetIdWithTokenId(uint256 assetType, uint256 tokenId) public view returns (uint256)

New L1 Vaults Functions

```
function depositERC1155ToVault(
    uint256 assetType,
    uint256 tokenId,
    uint256 vaultId,
    uint256 quantizedAmount
)
```

```
function withdrawErc1155FromVault(
    uint256 assetType,
    uint256 tokenId,
    uint256 vaultId,
    uint256 quantizedAmount
)
```

```
function getQuantizedErc1155VaultBalance(
    address ethKey,
    uint256 assetType,
    uint256 tokenId,
    uint256 vaultId
)
```

Updates

Gas Price

The maximum gas price is now 200 gwei.

Unique minting

  • Each new-minted ERC-721 token is unique.

  • The hash of the minted asset is stored in the orders tree

  • As part of this change, the StarkEx 4.5 order tree has changed from a Merkle tree into a Patricia tree. So during the upgrade to StarkEx 4.5, the orders root must change. As a result, the upgrade causes 0 time delay on the contract.