cross-chain
Cross-chain bridge and multi-chain development expertise. Supports LayerZero, Chainlink CCIP, Wormhole, and Axelar for omnichain messaging, token bridging, and cross-chain state verification.
What this skill does
# Cross-Chain Development Skill
Expert cross-chain bridge development and multi-chain integration.
## Capabilities
- **LayerZero**: Omnichain messaging and OFT tokens
- **Chainlink CCIP**: Cross-chain interoperability protocol
- **Bridge Verification**: Implement verification logic
- **Finality Handling**: Handle chain finality differences
- **Wormhole/Axelar**: Alternative bridge protocols
- **Canonical Bridges**: Token bridge implementations
- **State Verification**: Cross-chain state proofs
## LayerZero Integration
### OFT Token (Omnichain Fungible Token)
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { OFT } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/OFT.sol";
contract MyOFT is OFT {
constructor(
string memory _name,
string memory _symbol,
address _lzEndpoint,
address _delegate
) OFT(_name, _symbol, _lzEndpoint, _delegate) {
_mint(msg.sender, 1000000 * 10 ** decimals());
}
}
```
### OApp (Omnichain Application)
```solidity
import { OApp } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OApp.sol";
import { Origin } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/interfaces/IOAppReceiver.sol";
contract CrossChainCounter is OApp {
uint256 public count;
constructor(address _endpoint, address _owner) OApp(_endpoint, _owner) {}
function increment(
uint32 _dstEid,
bytes calldata _options
) external payable {
bytes memory payload = abi.encode(count + 1);
_lzSend(
_dstEid,
payload,
_options,
MessagingFee(msg.value, 0),
payable(msg.sender)
);
count++;
}
function _lzReceive(
Origin calldata _origin,
bytes32 _guid,
bytes calldata _message,
address _executor,
bytes calldata _extraData
) internal override {
uint256 newCount = abi.decode(_message, (uint256));
count = newCount;
}
}
```
### LayerZero Configuration
```typescript
// hardhat.config.ts LayerZero setup
import { EndpointId } from "@layerzerolabs/lz-definitions";
const config = {
networks: {
ethereum: {
url: process.env.ETHEREUM_RPC,
accounts: [process.env.PRIVATE_KEY],
},
arbitrum: {
url: process.env.ARBITRUM_RPC,
accounts: [process.env.PRIVATE_KEY],
},
},
layerZero: {
ethereum: {
eid: EndpointId.ETHEREUM_V2_MAINNET,
endpoint: "0x1a44076050125825900e736c501f859c50fE728c",
},
arbitrum: {
eid: EndpointId.ARBITRUM_V2_MAINNET,
endpoint: "0x1a44076050125825900e736c501f859c50fE728c",
},
},
};
```
## Chainlink CCIP
### Token Transfer
```solidity
import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IRouterClient.sol";
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract CCIPTokenTransfer {
IRouterClient public router;
address public linkToken;
constructor(address _router, address _link) {
router = IRouterClient(_router);
linkToken = _link;
}
function transferTokens(
uint64 destinationChainSelector,
address receiver,
address token,
uint256 amount
) external returns (bytes32 messageId) {
Client.EVMTokenAmount[] memory tokenAmounts = new Client.EVMTokenAmount[](1);
tokenAmounts[0] = Client.EVMTokenAmount({
token: token,
amount: amount
});
Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({
receiver: abi.encode(receiver),
data: "",
tokenAmounts: tokenAmounts,
extraArgs: "",
feeToken: linkToken
});
uint256 fee = router.getFee(destinationChainSelector, message);
IERC20(linkToken).approve(address(router), fee);
IERC20(token).approve(address(router), amount);
messageId = router.ccipSend(destinationChainSelector, message);
}
}
```
### Cross-Chain Message
```solidity
import {CCIPReceiver} from "@chainlink/contracts-ccip/src/v0.8/ccip/applications/CCIPReceiver.sol";
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
contract CCIPReceiver is CCIPReceiver {
event MessageReceived(bytes32 messageId, bytes data);
constructor(address router) CCIPReceiver(router) {}
function _ccipReceive(
Client.Any2EVMMessage memory message
) internal override {
emit MessageReceived(message.messageId, message.data);
// Process message
(string memory text) = abi.decode(message.data, (string));
// Handle the message...
}
}
```
## Wormhole Integration
### Token Bridge
```solidity
interface IWormholeTokenBridge {
function transferTokens(
address token,
uint256 amount,
uint16 recipientChain,
bytes32 recipient,
uint256 arbiterFee,
uint32 nonce
) external payable returns (uint64 sequence);
function completeTransfer(bytes memory encodedVm) external;
}
contract WormholeBridge {
IWormholeTokenBridge public bridge;
function bridgeTokens(
address token,
uint256 amount,
uint16 targetChain,
address recipient
) external payable {
IERC20(token).transferFrom(msg.sender, address(this), amount);
IERC20(token).approve(address(bridge), amount);
bytes32 recipientBytes = bytes32(uint256(uint160(recipient)));
bridge.transferTokens{value: msg.value}(
token,
amount,
targetChain,
recipientBytes,
0,
uint32(block.timestamp)
);
}
}
```
## Bridge Security Patterns
### Rate Limiting
```solidity
contract RateLimitedBridge {
uint256 public constant RATE_LIMIT = 1000000 * 1e18;
uint256 public constant RATE_PERIOD = 1 hours;
uint256 public currentPeriodStart;
uint256 public currentPeriodTransferred;
modifier rateLimited(uint256 amount) {
if (block.timestamp >= currentPeriodStart + RATE_PERIOD) {
currentPeriodStart = block.timestamp;
currentPeriodTransferred = 0;
}
require(
currentPeriodTransferred + amount <= RATE_LIMIT,
"Rate limit exceeded"
);
currentPeriodTransferred += amount;
_;
}
}
```
### Circuit Breaker
```solidity
contract CircuitBreakerBridge {
bool public paused;
address public guardian;
uint256 public pauseThreshold;
modifier notPaused() {
require(!paused, "Bridge paused");
_;
}
function pause() external {
require(msg.sender == guardian, "Only guardian");
paused = true;
}
function unpause() external {
require(msg.sender == guardian, "Only guardian");
paused = false;
}
function emergencyWithdraw(
address token,
address to,
uint256 amount
) external {
require(msg.sender == guardian, "Only guardian");
require(paused, "Must be paused");
IERC20(token).transfer(to, amount);
}
}
```
### Message Verification
```solidity
contract VerifiedBridge {
mapping(bytes32 => bool) public processedMessages;
mapping(uint256 => uint256) public chainConfirmations;
function processMessage(
bytes32 messageHash,
bytes[] calldata signatures,
uint256 sourceChain
) external {
require(!processedMessages[messageHash], "Already processed");
require(
verifySignatures(messageHash, signatures),
"Invalid signatures"
);
processedMessages[messageHash] = true;
// Process the message...
}
function verifySignatures(
bytes32 messageHash,
bytes[] calldata signatures
) internal view returns (bool) {
/Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.