# Migrating from Solidity++ 0.4
Comparing with Solidity++ 0.4, Solidity++ 0.8 is much syntactically closer to Solidity, which makes it more friendly to developers who want to migrate from Solidity.
Note: Some counter-intuitive syntax and keywords are removed in this version.
# Solidity++ 0.8.0
# Breaking Changes
- All Solidity breaking changes since v0.4.3 to v0.8.0 are applied to Solidity++ 0.8.0.
- Most of Solidity contracts and libraries can be compiled by solppc 0.8.0 and imported by Solidity++ 0.8.0 contracts, except for the contracts with external / delegate calls.
onMessage
keyword is deprecated since 0.8.0. Use function declarations instead.message
keyword is deprecated since 0.8.0. Usefunction
declared in acontract
orinterface
instead.send
keyword is deprecated since 0.8.0. Use function calls instead.getter
keyword is deprecated since 0.8.0. Useview
/pure
functions instead.- Inline assembly and Yul are supported since 0.8.0.
keccak256
is available since 0.8.0.tokenId
keyword (Vite Native Token Id type) is changed tovitetoken
.- Some transaction properties are changed since 0.8.0:
msg.tokenid
is changed tomsg.token
,msg.amount
is changed tomsg.value
.
# Compatibilities
- An external or public
function
(without return values) in 0.8.0 equivalents toonMessage
in 0.4.3. They have the same signature and selector. For examplefunction set(uint data) external
equivalents toonMessage set(uint data)
. - An external or public
function
declaration in 0.8.0 equivalents tomessage
declaration in 0.4.3. - A contract compiled by solppc 0.8.0 can call contracts compiled by solppc 0.4.3 asynchronously.
- A contract compiled by solppc 0.4.3 can call contracts compiled by solppc 0.8.0 asynchronously.
- The ABI encoding, storage layout, memory layout and calldata layout remain unchanged.
# Solidity++ 0.8.1
# Breaking Changes
- Solidity contracts and libraries with external / delegate calls can be compiled by solppc 0.8.1 and imported by Solidity++ 0.8.1 contracts.
await
operator is introduced since 0.8.1.- Error propagation through
revert
andtry/catch
is enabled since 0.8.1. - Delegate calls are allowed since 0.8.1.
- External / delegate calls in Solidity are allowed since 0.8.1.
- Library linking and calls to external library functions are allowed since 0.8.1.
# Compatibilities
- A contract compiled by solppc 0.8.1 can call contracts compiled by solppc 0.4.3 asynchronously.
- A contract compiled by solppc 0.8.1 can call contracts compiled by solppc 0.8.0 both synchronously and asynchronously.
- A contract compiled by solppc 0.8.1 can get return values after a synchronous call to a contract compiled by solppc 0.8.0.
- The ABI encoding, storage layout, memory layout and calldata layout remain unchanged.
# Migrate to 0.8.0
Let's start with an example:
In above code, contract A declares a message listener add(uint a, uint b)
.
contract B declares add
message which has the same signature to add
message listener in contract A.
Contract B declares a message listener invoke
as the entry to the contract. When B.invoke()
is called, contract B sends a add
message to contract A to initiate an asynchronous message call.
When contract A responds to the message call, it sends a sum
message back to contract B to return data asynchronously.
Contract B also declares a message listener sum(uint result)
as a 'callback function' to handle the returned message from contract A.
Since 0.8.0, onMessage
and message
are replaced with function
, send
statements are replaced with function calls. The await
operator is not available in 0.8.0, it is required to declare callbacks explicitly using function
.
The migrated code in 0.8.0 is as follows:
# Migrate to 0.8.1
Since Solidity++ 0.8.1, no explicit callback declarations are required.
The compiler is smart enough to generate callbacks automatically. The code is cleaner and optimized significantly by the introduction of await
.
The migrated code in 0.8.1 is as follows: