🥜
Peanut Docs
  • Learn
    • 🥜What is Peanut?
    • 🏦Cashout
      • Supported geographies
    • 📩How to use Peanut Links?
      • ⚙️How do Peanut Links Work?
      • 🔒Trust assumptions
    • 📌Use cases
    • 📚Case Studies
      • 🎁Welcome Packs
      • 📘Raffles to Boost UWAs and Transactions
      • 📗Sending Testnet Tokens at Hackathons
      • 📙IRL Events Marketing
    • ⛓️Supported Chains and Tokens
    • 💰Pricing
    • 🆘Support
  • Integrate
    • Using the SDK
      • Create ClaimLinks
        • Create Link
        • Batch Create Links
        • Create Raffle Links
        • Create Multi-Token Link
        • Create NFT Link
        • Create Gasless Links
        • Create Branded Links
      • Claim
        • Claim Link
        • Claim Gasless Link
        • Claim Cross-Chain Link
        • Claim Raffle Link
        • Claim Link as Sender (Reclaiming)
      • Create Request Link
      • Pay a Request Link
      • Pay a Request Link X-Chain
      • Utils
        • Get Link Details
        • Cross-chain
          • Get Supported Destination Chains
          • Get Supported Destination Tokens
          • Get Cross-Chain Options
          • Get Cross-Chain Route
        • Raffle (Legacy)
          • Get Raffle Info
          • Get User Raffle Status
          • Get Raffle Leaderboard
        • Get Default Provider
        • Get Supported Peanut Chains
        • Toggle Verbosity
        • EthersV5 <> Peanut Transaction Types
        • Estimate Fee Options
        • Get Random String
        • Get all deposits for an Address
        • Get Token Balance
      • API Keys
      • White-Labelling
      • Troubleshooting
      • SDK FAQ
    • Embedding an IFrame
    • Integrate Directly in Smart Contracts
    • Wallet Integrations
      • 🎬UI Examples
  • Other
    • 👾Bug bounties
    • 🔓Security Audit
    • 📜Peanut Protocol Contracts
  • BLOGS
    • Transfer Abstraction
    • Can We Sidestep Onchain Identity?
  • Additional Links
    • 🐦Twitter
    • 😊Telegram
    • 🤙Discord
    • 🥜Work with Us
    • 🎨Press Kit
    • 👨‍⚖️Contact and Legal
Powered by GitBook
On this page
  • Gasless Claiming
  • Claiming Yourself
  1. Integrate
  2. Using the SDK
  3. Claim

Claim Cross-Chain Link

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:

const xchainUnsignedTx = await peanut.populateXChainClaimTx({
    payload, // payload generated in createClaimXChainPayload.
    provider, // optional. Ethers provider connect to a node.
})

Notes

  • Be aware of the network fees and slippage settings if you pay the x-chain gas. Cross-chain claiming gas fees can be high depending on the source and destination chain.

  • The claimLinkXChainGasless function is convenient but remember that in the future it will have a 2% fee.

  • Always test your implementation in a testnet environment before deploying to production.

PreviousClaim Gasless LinkNextClaim Raffle Link

Last updated 1 year ago

Ensure you have the necessary environment variables set, particularly PEANUT_API_KEY if you are claiming though our API. Fill out form to get your very own peanut-api-key!

For further information or support, feel free to join our or send a message via .

this
Discord
Telegram