Claim on Any Chain in Any Token

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:

  1. Gasless claim through our API/relayer. We will execute the transaction and pay all the transaction + bridging fees, but we will take a small portion of the Link's amount as a compensation. Currently we take 2%.
  2. Claim by signing the transaction yourself. This way you will have to execute the transaction on the source chain and pay the bridging fee, but there will be no Peanut-specific fee involved.

Gasless Claiming

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.
})

Claiming Yourself

To claim a Link by signing the transaction yourself, follow these three steps:

  1. Create a cross-chain claiming payload via createClaimXChainPayload function.
  2. Create an Ethersv5 transaction request out of this payload by using populateXChainClaimTx function.
  3. Sign the transaction request with your own wallet & submit it to the blockchain. There is a helpful 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: