Send

Endpoint to request query

Execute this function via an interface from a User-defined contract In this case, it is necessary to send the fee to be paid to Relayer as msg.value.

struct QueryRequest {
  uint32 dstChainId;
  address to;
  uint256 height;
  bytes32 slot;
}

function query(
  QueryRequest[] memory queries,
  address lightClient,
  address callBack,
  bytes calldata message
) external;
Field
Description

queries

An array of QueryRequest data

lightClient

The address of the contract is to be verified

callBack

The address of the contract to return the data to

message

Data to be returned, in addition to the query

What the query function does:

  • Encode the query data

  • Calculate the query Id

  • Execute the light client process as necessary

    • Currently, sending a request to Chainlink's Node Operator

  • Emit a request event

  • Pay fees to Relayer

    • Calculate the transaction fee off-chain and send the token based on it

Calculate the query Id

bytes memory encodedPayload = abi.encode(
	callBack,
	queries,
	message,
	lightClient
);
bytes32 queryId = keccak256(abi.encode(encodedPayload, nonce));

Encode each field and the nonce again and hash it as queryId.

Emit a request event

Events are emitted with the following structure;

event Packet(
	address indexed sender,
  	bytes32 indexed queryId,
	bytes packet,
	bytes message,
	address lightClient,
	address callBack
);
Field
Description

sender

An user who executed the contract

queries

An array of QueryRequest data

packet

callBack, queries, message, lightClient encoded

message

Data to be returned, in addition to the query

lightClient

The address of the contract is to be verified

callBack

The address of the contract to return the data to

Last updated