LayerZero-Labs / LayerZero-v1

An Omnichain Interoperability Protocol
Other
1.96k stars 1.25k forks source link

Adress format expected for 'sendFrom' is bytes32 in OFTv2 ? #25

Closed PoCk3T-SPAI closed 1 year ago

PoCk3T-SPAI commented 1 year ago

Hello LayerZero team & community,

Small technical challenge I'm facing here with LZ OFTv2, appreciate any insights or feedbacks anyone would be able to share with me :)

Context:

Problem:

Question:

PoCk3T-SPAI commented 1 year ago

Answering to myself thanks to the help of the dev team on Discord: LzApp has 2 functions for setting trusted remote - setTrustedRemote and setTrustedRemoteAddress. They are interchangeable. Please refer to the contract code. When calling setTrustedRemote you need to supply the pathway (encodePacked(remoteAddress,localAddress)), but when calling setTrustedRemoteAddress you need to supply a remote address. The pathway encoding will be performed in the contract function.

image

Using setTrustedRemote ended up working for me.

In Python with ApeX/ape library, it translates into:

from eth_abi.packed import encode_packed
remoteEndpoint = encode_packed(['address', 'address'], [remote_contract_addr, base_contract_deployed.address])
base_contract_deployed.setTrustedRemote(_remote_chain_id, _remoteEndpoint, sender=account)