StarkNet Alpha 0.7.0
Spoiler — massive version alert!
- StarkNet Alpha 0.7.0 released to Goerli; packed with improvements
- Contracts can now be upgraded using the Proxy Upgrade Pattern
- Contracts can now emit Events
- Support for the long-awaited Block Number and Block Timestamp system calls
We are happy to release Alpha 0.7.0, a version packed with new features and improvements. One of the best stimulants to StarkNet over the last few months has been the increased involvement of the community in shaping StarkNet’s future. This version addresses some of the community’s burning needs.
Changes to Naming Convention
The observant reader might have noticed that the previous StarkNet Alpha release was named Alpha 4, whereas we are now releasing Alpha 0.7.0. We decided to omit the dedicated Alpha version number and rely instead only on the associated cairo-lang version.
OpenZeppelin’s Proxy Upgrade Pattern is now fully supported for contract upgrades in StarkNet. The Proxy pattern is the common method to enable contract upgrades over Ethereum. Alpha 0.7.0 enables this pattern over StarkNet.
Block Number and Block Timestamp
Alpha 0.7.0 adds two new system calls that many devs have been asking for. These calls allow a contract to access the block number and the block timestamp. The block number returns the number of the current executed block. The block timestamp returns the timestamp given by the Sequencer at the creation of the block.
You can see an example of how to use these features in the tutorial.
Surprise! A feature that was planned for a future version has sneaked its way into this earlier one.
StarkNet contracts now support defining and emitting events, allowing them to expose execution information for off-chain applications to consume. Ethereum developers will find the semantics and syntax very similar to Solidity. You can read the documentation, or follow the tutorial, that explains this feature.
Removed %builtins Directive
The %builtin directive is no longer needed in StarkNet contracts. This change followed a community discussion about the contract extensibility pattern on StarkNet Shamans. It significantly simplifies the usability of this extensibility pattern.
For example, the following contract will be changed from:
# This is the "%builtins" directive.# It is not needed anymore.%builtins range_check
@viewfunc add(x : felt, y : felt) -> (res : felt):return (res=x + y)end
%lang starknet@viewfunc add(x : felt, y : felt) -> (res : felt):return (res=x + y)end
You can check out the ERC-20 standard contracts, which use the new pattern.
External Functions Support Arrays of Structs
Alpha 0.7.0 supports passing and returning arrays of structs in external functions. This additional functionality allows Account Contracts to better support multicalls.
Multicall is a powerful feature of Account Abstraction that allows an account to make multiple calls in a single transaction. An obvious use-case is that of creating a single transaction that calls allowance and then transferFrom.
We look forward to seeing what the community does with it.
Improvements to StarkNet CLI
Support for Pending Blocks
To use it, in every CLI command that takes block_number as an argument (contract_call/get_block/get_code/get_storage_at), we can query the StarkNet with respect to the pending block by specifying block_number=pending.
Support for Account Contracts
In StarkNet, all transactions must go through an account contract, and the CLI now allows interaction with StarkNet Alpha directly via account contracts. See the tutorial on how to set it up.
L1<>L2 Messaging in the Testing Framework
Alpha 0.7.0 introduces the Postman. The Postman enables developers to use the testing framework to test more complicated flows.
At a high level — it mocks the StarkNet Sequencer’s responsibility of passing messages from L1 to L2 and L2 to L1. It makes sure messages that are sent via the Solidity messaging contract will appear at the destination StarkNet contract and messages sent from a StarkNet contract will appear in the Solidity messaging contract.
And More Features
Alpha 0.7.0 provides many more features and changes, like the addition of an efficient square root function to the math common library. A full list appears in the changelog.
Initial Fee Mechanism support will be released in a matter of weeks, as a sub-version of StarkNet.