Cross-Chain claiming (also called "X-Chain" for short) provides a seamless and flexible way to claim tokens across different blockchain networks. There are 2 primary approaches to claim links cross-chain:
To claim a Link gaslessly through our API, use the claimLinkXChainGasless
function:
const result = await peanut.claimLinkXChainGasless({
link, // the entire link as string.
recipientAddress, // receipient address on the destination chain.
destinationChainId, // id of a supported destination chain.
destinationToken, // optional. address of the token on the destination chain, 0x00..00 for native token. If not specified, the address of the token on the source chain is used.
APIKey, // api key for the relaying API.
baseUrl, // optional. Use if you have a custom realying api that the link should be claimed through.
squidRouterUrl, // optional. Use if you want to get squid data from a custom endpoint.
isMainnet, // optional. Use when experimenting on testnets. Default: true.
slippage, // optional. Max slippage when swapping between source and destination tokens.
})
To claim a Link by signing the transaction yourself, follow these three steps:
createClaimXChainPayload
function.populateXChainClaimTx
function.signAndSubmitTx
function.The following are helpful cross-chains functions.
createClaimXChainPayload
To use the createClaimXChainPayload
function, follow the code snippet below:
const xchainClaimPayload = await peanut.createClaimXChainPayload({
destinationChainId,
destinationToken, // optional. address of the token on the destination chain, 0x00..00 for native token. If not specified, the address of the token on the source chain is used.
link, // the entire link as string.
recipient, // receipient address on the destination chain.
squidRouterUrl, // optional. Use if you want to get squid data from a custom endpoint.
isMainnet, // optional. Use when experimenting on testnets. Default: true.
slippage, // optional. Max slippage when swapping between source and destination tokens.
})
populateXChainClaimTx
To use the populateXChainClaimTx
function, follow the code snippet below: