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
vaultIdmust be on. The roots of both vault trees are updated when
UpdateStateis 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.
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.
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
assetTypesresult in different
ERC1155_SELECTOR = bytes4(keccak256("ERC1155Token(address,uint256)"))
ERC-1155 tokens are deposited and withdrawn similarly to NFTs, including
tokenId, but also including a
tokenIdis the internal token id within the ERC-1155 contract.
assetIdis a unique StarkEx identifier calculated as follows:
uint256(keccak256(abi.encodePacked("NON_MINTABLE:", assetType, tokenId))) & MASK_250
Deposit for both ERC-721 and ERC-1155, recommended. For ERC-721,
quantizedAmountmust equal one:
function depositWithTokenId( uint256 starkKey, uint256 assetType, uint256 tokenId, uint256 vaultId, uint256 quantizedAmount )
A wrapper for
depositWithTokenIdthat 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)
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 )