We will open more info about solidity++, please stay tuned.
The most difference between eth and vite are:
- Communication between contract is asynchronous
- In solidity++, it's more like a asynchronous programming
For example:
In solidity:
contract B {
function add(uint a, uint b) returns (uint ret) {
return a + b;
}
}
contract A {
uint total;
function invoker(address addr, uint a, uint b) {
// message call to A.add()
uint sum = B(addr).add(a, b);
// use the return value
if (sum > 10) {
total += sum;
}
}
}
In solidity++:
pragma solidity++ ^0.1.0;
contract B {
message Add(uint a, uint b);
message Sum(uint sum);
Add.on {
// read message
uint a = msg.data.a;
uint b = msg.data.b;
address sender = msg.sender;
// do things
uint sum = a + b;
// send message to return result
send(sender, Sum(sum));
}
}
contract A {
uint total;
function invoker(address addr, uint a, uint b) {
// message call to B
send(addr, Add(a, b))
// you can do anything after sending
// a message other than using the
// return value
}
Sum.on {
// get return data from message
uint sum = msg.data.sum;
// use the return data
if (sum > 10) {
total += sum;
}
}
}