---
# System prepended metadata

title: We just released ink! 4.0!

---

# We just released ink! 4.0!

![](https://i.imgur.com/QsDH5p9.jpg)

ink! is a programming language for smart contracts — one of several that blockchains built with the Substrate framework can choose from. It is an opinionated language that we at Parity have built by extending the popular Rust programming language with the functionality needed to make it smart contract compatible. For more details see our article [What is Parity's ink!?](https://www.parity.io/blog/what-is-paritys-ink).

We just published the next major iteration of ink! ‒ `v4.0`. In this article, we want to highlight the big themes of this release.

## Storage Abstraction

A big change in this release is how developers interact with their smart contract's storage. This also affects third-party tools, such as block explorers that display the data a contract stores. 

We've taken our learnings from ink! 3.x and completely overhauled our storage abstraction. This has two major benefits:
* It makes it easier for developers to understand ink!. Our prior abstraction was complex and required developers to write substantial boilerplate code for custom data structures. We think we have a more intuitive, clearer design now with several comfortable `Derive` implementations.
* The new storage setup reduces the footprint of our contracts on-chain. This is due to reduced complexity in ink!. You can think of it this way: our new abstraction is less complex; it has been implemented with less code, resulting in fewer instructions that will be part of your final contract blob. A smaller contract footprint on-chain translates to fewer costs for users to interact with a contract, as well as higher throughput that the chain on which the contract is deployed can achieve.

This work has been done in collaboration with [@xgreenx](https://github.com/xgreenx) from [Supercolony](https://github.com/Supercolony-net) under a Web3 Foundation grant. Thank you to everyone who contributed to this effort!

## End-to-End Testing Framework

![](https://i.imgur.com/IsKkgJ6.png)

With ink! 4.0 we are introducing an End-to-End (E2E) testing framework.

Until now, ink! supported classic unit and integration testing:
* Unit tests for an ink! contract can be written as they are for any other Rust program: using the `#[test]` annotation.
* For integration tests, the test is annotated with our `#[ink::test]` attribute instead. This attribute denotes that the test is then executed in a simulated, mocked blockchain environment. There are functions available to influence how the test environment is configured (e.g. setting a specified balance of an account to simulate how a contract would behave when interacting with it).

Through technical advances in Substrate (namely [Metadata v14](https://github.com/paritytech/substrate/pull/8615), which Andrew from the ink! team implemented) and improvements in `subxt` it is now possible for us to introduce a component that we have been dreaming about for a long time: end-to-end testing. In short, you are no longer limited to testing contracts in an artificial world -- instead, you can now do so in the real one!

E2E testing enables developers to write a test that will not only test the contract in an isolated manner; instead, the contract will be tested _together_ with all components that will be involved on-chain -- so from end to end. This way of testing resembles closely how the contract will actually behave in production. 

As part of the test, the contract will be compiled and deployed to a Substrate node that is running in the background. We offer API functions that enable developers to then interact with the contract via transactions that they create and submit to the blockchain. Developers can define assertions on the outcome of their transactions, such as checking for state mutations, transaction failures or incurred gas costs.

Your chain configuration will be tested together with the smart contract. And if your chain has pallets that are involved with the smart contract execution, those will be part of the test execution as well.

We don't put any requirements on the Substrate node in the background -- for example, you can run a node that contains a snapshot of a live network. 

This is a big step forward and we see E2E as the last stone in the ink! testing pyramid. With this, we can now confidently say that ink! offers a complete smart contract testing story to developers.

## Metadata v4

We have reworked the metadata format that ink! uses. This makes it easier for third-party tools (like block explorers) to interact with ink! smart contracts and extract information from deployed contracts.

Our new format comes with proper documentation and formal specification. You can find the documentation of the new format [here](https://use.ink/4.0.0-alpha.1/metadata). The formal specification is available as a JSON schema [here](https://github.com/paritytech/ink/tree/master/crates/metadata). The formal schema can be used by block explorers to verify contract metadata that is uploaded by users.

## More changes

There are a number of other changes that we won't go into detail here. You can find details in our release notes [here](https://github.com/paritytech/ink/releases/tag/v4.0.0).

The general theme is that we made the ink! API more Rust idiomatic, enabling Rust developers a more intuitive usage of ink!. ink! now also supports [a registry for chain extensions](https://github.com/paritytech/chainextension-registry). This enables developers to use extensions of `pallet-contracts`, e.g. to enable smart contracts to access to the `pallet-assets`.

## `cargo-contract` 2.0

Together with ink! 4.0 we are releasing the next major iteration of [`cargo-contract`](https://github.com/paritytech/cargo-contract) -- our Swiss Army knife for anything regarding ink! contracts.

`cargo-contract` 2.0 comes with the support of ink! 4.0 and a lot of small improvements for interacting with deployed contracts. Check out the release notes [here](https://github.com/paritytech/cargo-contract/releases/tag/v2.0.0).


## Further Information

We have written a migration guide from ink! 3.x to 4.0. You can find it on our documentation portal [here](https://use.ink/getting-started/migrating-from-ink-3-to-4).

Our documentation portal is versioned now. It contains a dropdown in the top-right corner to switch the version. The changes in ink! 4.0 are documented there. 
In case you run into any issues with ink!, the best way to get help is to either:

* Post a question on [the Substrate Stack Exchange](https://substrate.stackexchange.com/questions/tagged/ink/). There is a tag for ink! and smart contracts.
* In case you think this could be a bug, or you have a feature suggestion, it's best to create an issue in [the ink! repository](http://github.com/paritytech/ink) on GitHub.

## Compatibility

ink! 4.0 is compatible with the `pallet-contracts` released with Polkadot release `polkadot-v0.9.37`.

Our latest `substrate-contracts-node` (version `v0.23.0`) also supports ink! 4.0.

## What's next?

The next big item on our roadmap is to integrate support for XCM into ink!. Our current thinking is that we can do this without breaking changes, e.g. with an ink! 4.1 release.

## Thank you!

ink! is an open source project and numerous people besides the core team have contributed to this release.

Thank you everyone!
