stellar / rs-soroban-env

Rust environment for Soroban contracts.
Apache License 2.0
61 stars 42 forks source link

Support for abi encode and decode. #1084

Open re1ro opened 1 year ago

re1ro commented 1 year ago

What problem does your feature solve?

This feature would add ability to write interchain dapps and support any kind of communication between Soroban and EVM smart contracts.

What would you like to see?

Natively exposed functions for abi encoding and decoding with a reasonable gas cost. Maybe this could use the existing rust implementation of ethabi underneath

What alternatives are there?

Importing ethabi into the contract itself, but it becomes expensive in terms of gas usage and deployment. Alternatively some custom packing unpacking could be implemented (for predefined data structure) but that would not allow flexibility and dynamic data types.

namankumar commented 7 months ago

Here is a sample of how abi encoding/decoding may be used: function call, spec

And here are existing rust crates that could be potentially used for the implementation:

  1. The implementation included in Alloy has an abi encoder/decoder implementation and supports no_std and wasm target
  2. The implementation from rust-ethereum
leighmcculloch commented 7 months ago

@re1ro When embedding the eth abi did you do something like what this example does? https://github.com/stellar/soroban-examples/tree/6c27ca6211ae04d5393cf16590e7da84f1d1f3f5/eth_abi

If you'd like to propose a change to the protocol, which adding a host function would be, could you start a stellar-protocol discussion at https://github.com/stellar/stellar-protocol/discussions?

Could you share more details about the size / cost with numbers and example contracts in that discussion?