Build your first XCDP - EVM Contract
Step by Step guide and Repository link provided in Templates Section. In this guide we will use Sepolia and bscTestnet to deploy the client chain contracts and L1X TestNet to deploy X-Talk Contract.
Implementing Solidity Contract (Comments for Explanation)
//XCDPCore.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/* XCDP Core to implement the interface.*/
contract XCDPCore {
address public gatewayContractAddress = DESTINATION_X-TALK_GATEWAY_CONTRACT_ADDRESS; //Provided in endpoint
mapping(bytes32 => XCDPReceiveMessage) public XCDPData;
/* Sending message instruction. You can make this
compatible with Destination or if you want to transform
the message on X-Talk you can send raw instructions and
prepare the payload on X-Talk Contract*/
struct XCDPSendMessage {
string message;
}
/* Same with Receiving the message where you will be
able to provide any struct based on how you want to
receive it based on the transformed payload */
struct XCDPReceiveMessage {
string message;
}
/* This is the encoded format of the paylaod to be
sent. This will be sent to X-Talk Contract. Provide
destination details here or add it into X-Talk if you
want to run logic and decide where to send the paylaod */
event XTalkMessageBroadcasted(
bytes message,
string destinationNetwork,
string destinationSmartContractAddress
);
/* This is the function to be called when you want to
send the message. The message is encoded into bytes
before emitting */
function _l1xSend(
string memory message,
string memory destinationSmartContractAddress,
string memory destinationNetwork
) external {
XCDPSendMessage memory myMessage = XCDPSendMessage({
message: message
});
// Convert the struct to bytes
bytes memory messageBytes = abi.encode(myMessage.message);
emit XTalkMessageBroadcasted(messageBytes, destinationNetwork, destinationSmartContractAddress);
}
/* decoding the message to retrieve the stringified message,
and storing it along with the global transaction id ( the message identifier ) */
function _l1xReceive(bytes32 globalTxId, bytes memory message) external {
require(msg.sender == gatewayContractAddress, "Caller is not xtalk node");
XCDPReceiveMessage memory XCDPReceiveMessageData;
(XCDPReceiveMessageData.message) = abi.decode(message, (string));
XCDPData[globalTxId] = XCDPReceiveMessageData;
}
}Implementing L1X X-Talk Flow Contract
Create Wallet
Register Client Chain and X-Talk Contracts with X-Talk Node
Send the Event

X-TALK GATEWAY CONTRACT ADDRESS
Network
Contract Address
Previousv1.0 (Legacy )NextBuild your first XCDP - Solana to EVM Contract and XCDP - EVM to Solana Contract
Last updated