CALLDATA
"@butternetwork/omniservice/contracts/interface/IMOSV3.sol";
contract A {
//The contract address of OmniService on chain A
IMOSV3 public imosv3;
mapping(string => string) public dictionaryList;
mapping(address => bool) public whitelist;
function setDictionaryEntry(
string memory _key,
string memory _val
) external {
}
function sendDictionaryCalldata(
uint256 _tochainId, //The chain ID of the target chain.
bytes memory _target, //The contract address on the target chain.
string memory _key //The message key on chain A.
) external payable {
//Encode the message that needs to be cross-chain.
bytes memory data = abi.encodeWithSelector(A.setDictionaryEntry.selector,_key,dictionaryList[_key]);
IMOSV3.MessageData memory mData = IMOSV3.MessageData(
false,
IMOSV3.MessageType.CALLDATA, ///Select CALLDATA for cross-chain transmission.
_target,
data,
500000,
0
);
//Encode the MessageData structure for cross-chain transmission.
bytes memory mDataBytes = abi.encode(mData);
//Retrieve the amount of fee required for cross-chain transaction.
(uint256 amount, ) = imosv3.getMessageFee(_tochainId, address(0), 500000);
//Initiate the cross-chain request using OmniChain Service
imosv3.transferOut{value: amount}(_tochainId, mDataBytes, address(0));
}
}Last updated