Open ytqaljn opened 2 weeks ago
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 _extraOptions
, and combines them with the _enforcedOptions
to determine the total amount of gas you are requesting on the destination chain.
Look at the line with combineOptions()
.
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:
You said that you cannot provide a null value to extraOption without setting setEnforcedOptions. I have set setEnforcedOptions now, so I passed 0x to extraOption, but it still reports an error.
If I don't set it, can my extraOption pass the sample value in the document: 0x00030100110100000000000000000000000000000000ea60
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?
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.