Starknet Alpha 0.7.0

Spoiler — massive version alert!

StarkWare
Published in
4 min readJan 18, 2022

--

TL;DR

  • 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

Intro

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.

New Features

Contract Upgradeability

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.

We made a short tutorial to demonstrate a basic implementation of the pattern, and OpenZeppelin is already hard at work implementing a standard contract for the proxy pattern; see the prototype.

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.

Events

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:

%lang starknet
# This is the "%builtins" directive.
# It is not needed anymore.%builtins range_check
@view
func add(x : felt, y : felt) -> (res : felt):return (res=x + y)end

To this:

%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

Pending Blocks were introduced in the last minor version (v0.6.2) and offered faster confirmations on transactions. This version includes support for querying those blocks via the Starknet CLI.

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

Starknet uses account abstraction, i.e., all accounts are implemented as smart contracts. The first implementations of account contracts were done by Argent and OZ, but we expect many more to come.

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.

Similar functionality was also added to Starknet.py and to Nile in the last month.

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.

Next Up?

Initial Fee Mechanism support will be released in a matter of weeks, as a sub-version of Starknet.

More Information?

starknet.io: for all Starknet information, tutorials and updates.

Starknet Discord: join to get answers to your questions, get dev support and become a part of the community.

Starknet Shamans: join to follow (and participate!) in Starknet research discussions.

--

--