Closed lowesyang closed 5 years ago
Currently it uses the same Contract ABI encoding design to be compatible with EVM.
e.g. the main
function will use callDataCopy
to retrieve the call data (input) as in EVM and use finish
to return the output.
Can i explicitly define the main
function in the contract, and how? It's better to have some examples~
I agree, we're working on the documentation at https://github.com/ewasm/testnet which should include these.
Here's an example contract in Rust: https://github.com/ewasm/ewasm-precompiles/blob/master/sha256/src/lib.rs
So main
function may do the things below:
0xedfdfdfd
with 4 bytes.finish
to return the output.is that right?
Correct, it has to implement ABI handling on its own. Just like it is happening in EVM at the moment.
We're exploring other options though, see the umbrella issue #1
Got that, thanks very much!
Maybe an automatically ABI handling just like in EVM is very in need, cause developers don't need to write the dispatcher themselves~
Can we close in favor of #1? Let's continue the conversation there
We'd need to document this for clarity though.
ECI spec tells us that every contract will export a
main
function with no parameters and returns. But i have two questions:main
function generally for?