NEWTON
Asked
3 months ago
58
views
0
I'm aware of starknet having a common--and unsafe--keccak library. Either way, I was wondering if there's a way to mimic the behavior of solidity's
keccak256(abi.encode(parameters))
Thank you very much.
0x57B0...F5A4FD
asked
3 months ago
1
Accepted answer
At the moment this is not possible since there is no real typing system, though this might change with Cairo 1.0.
What you can do is to simply use structs to pass calldata between contracts instead of encoding/decoding.
For reference, the same function with calldata on both EVM and Starknet with encode/decode:
EVM (with encode/decode): https://github.com/CygnusDAO/periphery/blob/main/contracts/cygnus-periphery/CygnusAltairX.sol#L849
Cairo (without encode/decode): https://github.com/CygnusDAO/starknet-periphery/blob/main/src/cygnus_periphery/cygnus_altair_x.cairo#L968
Anubis
answered
3 months ago
Equivalent to Solidity's keccak256(abi.encodePacked())?
How to modify keccak.cairo and/or packed_keccak.cairo to compute a 512bits keccak hash instead of 256 bits?
Is there any way to abi-encode calldata to pass to `account.execute`?
why does keccak256 replace sha256 in warp?
Why abi of warp compiled contract does not match original solidity abi?
How to check if a contract has been deployed at a certain address in cairo?
Cairo error: Unknown identifier 'bitwise_ptr' when using keccak
Hey, is there anyway to debug Cairo contracts in hardhat environment? Something like hardhat console in solidity
Writing a "not" operation in Cairo
Revoked References exercise from Cairo-lang
How to write a struct in storage?
Cairo: Using less than or greater than in conditional
How to make output like "hello world" in Cairo Language (StarkNet)?
when starknet token?