# Migrating from Solidity
# Solidity Compatibility
Solidity++ 0.8 is compatible with almost all syntax of Solidity, except for a few differences which will be introduced below.
All features related to Ethereum are replaced with the counterparts in Vite.
Note: The
new
keyword is disabled in this version. In other words, it is impossible to deploy a new contract from a contract at runtime. In addition,selfdestruct
andecrecover
are disabled in this version.
# Types
Type address
is redefined to be compatible with Vite, and a new type vitetoken
representing Vite Native Token Id is introduced in Solidity++.
# Call Options
When calling functions of other contracts, it is possible to specify the amount of a specific token sent with the call in call options, e.g. {token: "tti_564954455820434f494e69b5", value: 1e18}
.
If property token
is omitted, the VITE token is sent by default.
That says, the following code
is equivalents to
Notice
Property gas
and salt
in call option are not supported in Solidity++.
# Units
In Solidity, a literal number can take a suffix of wei
, gwei
or ether
to specify a subdenomination of Ether, where Ether numbers without a postfix are assumed to be wei
.
Similarly, in Solidity++, a literal number can take a suffix of attov
and vite
to specify a subdenomination of VITE, where VITE numbers without a postfix are assumed to be attov
.
# Special Variables and Functions
# Block and Transaction Properties
Below special variables and functions has been removed in Solidity++:
Below special variables and functions has been added in Solidity++:
fromhash()
returns request transaction's hashaccountheight()
returns latest block height of an accountprevhash()
returns latest block hash of an accountrandom64()
returns a random number inuint64
. This function will return the same random number in one transactionnextrandom()
returns a random number inuint64
. This function can be called multiple times to obtain different random numbers in one transaction
Get transfer value (Ether) in Solidity:
Get transfer value and token id in Solidity++:
# Members of Address Types
Get account balance in Solidity:
Get account balance in Solidity++, balance is a function with a single parameter of vitetoken
:
In Solidity, send Ether to an address:
In Solidity++, send some amount of a specific token to an address:
# Cryptographic Functions
A new hash function blake2b
is introduced in Solidity++.
- Compute the Blake2b hash of the input.