-
Notifications
You must be signed in to change notification settings - Fork 350
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
Help: My cross-chain contract failed when calling the quoteSend transaction. #80
Comments
Did you call setEnforcedOptions? You need to provide at least some execution options either as enforced or extra in order for the quote to succeed. https://docs.layerzero.network/v2/developers/evm/oft/quickstart#message-execution-options |
Hmm, I didn't call it, I thought I didn't need to call it if I didn't force extra options. So what value do I need to pass it? If there are no extra options. Do you mean I need to call setEnforcedOptions? Or do I need to pass a value to the _option field when I call quoteSend? |
Hello, @St0rmBr3w I have now successfully called setEnforcedOptions. My call parameters are as follows: But I still get an error when I call _quoteSend later. Below are my calling parameters and the error: |
You don't need to setEnforcedOptions, but you will need to then pass a bytes array to extraOptions. The way the OFT Standard works is it takes the Look at the line with function _buildMsgAndOptions(
SendParam calldata _sendParam,
uint256 _amountLD
) internal view virtual returns (bytes memory message, bytes memory options) {
bool hasCompose;
// @dev This generated message has the msg.sender encoded into the payload so the remote knows who the caller is.
(message, hasCompose) = OFTMsgCodec.encode(
_sendParam.to,
_toSD(_amountLD),
// @dev Must be include a non empty bytes if you want to compose, EVEN if you dont need it on the remote.
// EVEN if you dont require an arbitrary payload to be sent... eg. '0x01'
_sendParam.composeMsg
);
// @dev Change the msg type depending if its composed or not.
uint16 msgType = hasCompose ? SEND_AND_CALL : SEND;
// @dev Combine the callers _extraOptions with the enforced options via the OAppOptionsType3.
options = combineOptions(_sendParam.dstEid, msgType, _sendParam.extraOptions);
// @dev Optionally inspect the message and options depending if the OApp owner has set a msg inspector.
// @dev If it fails inspection, needs to revert in the implementation. ie. does not rely on return boolean
if (msgInspector != address(0)) IOAppMsgInspector(msgInspector).inspect(message, options);
} This is the combineOptions function. function combineOptions(
uint32 _eid,
uint16 _msgType,
bytes calldata _extraOptions
) public view virtual returns (bytes memory) {
bytes memory enforced = enforcedOptions[_eid][_msgType];
// No enforced options, pass whatever the caller supplied, even if it's empty or legacy type 1/2 options.
if (enforced.length == 0) return _extraOptions;
// No caller options, return enforced
if (_extraOptions.length == 0) return enforced;
// @dev If caller provided _extraOptions, must be type 3 as its the ONLY type that can be combined.
if (_extraOptions.length >= 2) {
_assertOptionsType3(_extraOptions);
// @dev Remove the first 2 bytes containing the type from the _extraOptions and combine with enforced.
return bytes.concat(enforced, _extraOptions[2:]);
}
// No valid set of options was found.
revert InvalidOptions(_extraOptions);
} If you don't setEnforcedOptions AND don't provide an extraOption, you are not passing in any destination gas settings and the call will revert. |
Thank you, I have two questions now:
In addition, the error message I currently receive is not InvalidOptions(_extraOptions) , but Error: call revert exception @St0rmBr3w Could you please tell me how to solve this error? Or is it a problem with extraOptions? |
Is there a reason you're passing 0x1 as an input to quoteSend? |
@St0rmBr3w There's no particular reason, in fact, I've tried all these different parameters and they all failed. The value I passed at: After failing, I passed: And I have currently set up setEnforcedOptions |
@St0rmBr3w |
Hi, I generated an OFT contract according to your Create LZ OApp Quickstart, and then modified the relevant configurations to successfully deploy them to two networks with LZ Endpoint.
Now I successfully called
setPeer
through my calling script, andisPeer
also returned true.But when I started calling my
quoteSend
, it returned an error.Here are the parameters I sent when calling, I am not sure if they are correct:
Here is the error:
Node.js v22.1.0
Can anyone help me solve my problem? Thank you.
The text was updated successfully, but these errors were encountered: