Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EVM] Add support for abi.encode() and abi.decode() to Cadence #4937

Closed
franklywatson opened this issue Nov 3, 2023 · 4 comments · Fixed by #5024
Closed

[EVM] Add support for abi.encode() and abi.decode() to Cadence #4937

franklywatson opened this issue Nov 3, 2023 · 4 comments · Fixed by #5024

Comments

@franklywatson
Copy link
Contributor

Issue to be solved

The Axelar cross-chain integration work needs the Ethereum ABI.encode() and ABI.decode() functionality made available, ideally as a native Cadence language function owing to the difficulty of implementing the same logic directly in Cadence code due to the byte level handling. This need will doubtless also arise for other aspects of EVM integration in future since ABIs are very common.

The reference example in https://github.com/ethereum/go-ethereum/blob/master/accounts/abi/abi.go could in theory be copy-pasted along with tests and then surface language native methods to invoke that logic.

Suggested Solution

This task is to confirm the feasibility of this, and confirm the naming and spec for the Cadence native functions that would allow Cadence code to run the ABI.encode() and ABI.decode() through them.

** Definition of done **

  • Cadence native language functions for ABI.encode() and ABO.decode() are available in the Cadence runtime
  • Tests exist which assert that encode/decode functionality works identically to the Ethereum version
  • Tests exist to assert the integration of the functionality in Cadence
@bluesign
Copy link
Contributor

bluesign commented Nov 6, 2023

nit: I think place for this is in flow-go [0] [1]
should be something like evm.encodeABI and evm.decodeABI ( though @turbolent and @ramtinms knows better )

[0] https://github.com/onflow/flow-go/blob/643b532c77eacc4d8b34232afaa8c7416a1cd912/fvm/evm/stdlib/contract.cdc
[1] https://github.com/onflow/flow-go/blob/643b532c77eacc4d8b34232afaa8c7416a1cd912/fvm/evm/stdlib/contract.go

@turbolent
Copy link
Member

Yes, this should be implemented in the EVM contract defined in flow-go, this is not a part of Cadence. Moving

@turbolent turbolent transferred this issue from onflow/cadence Nov 6, 2023
@ramtinms
Copy link
Contributor

ramtinms commented Nov 6, 2023

I don't think this request is a Flow-EVM related request. It's a request similar to what we did for RLP.

@ramtinms
Copy link
Contributor

ramtinms commented Nov 6, 2023

Thought we might decide to do it inside the EVM contract, its implementation is not dependent on the Flow-EVM work in my view.

@franklywatson franklywatson changed the title [EVM] Add support for abi.encode() and abi.decode() to Cadence [Flow EVM] Add support for abi.encode() and abi.decode() to Cadence Nov 8, 2023
@franklywatson franklywatson changed the title [Flow EVM] Add support for abi.encode() and abi.decode() to Cadence [EVM] Add support for abi.encode() and abi.decode() to Cadence Nov 8, 2023
@franklywatson franklywatson added this to the Emulator Beta release milestone Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants