🥜
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 Depositing
  • Gasless Depositing Happens in 3 steps
  1. Integrate
  2. Using the SDK
  3. Create ClaimLinks

Create Gasless Links

We even support creating links where we sponsor the gas!

PreviousCreate NFT LinkNextCreate Branded Links

Last updated 1 year ago

Gasless Depositing

Gasless depositing works via . USDC supports EIP-3009.

Gasless Depositing Happens in 3 steps

1. Create Payload & Message

Create a payload to submit to the Peanut Smart Contract. This involves an EIP-712 message to be signed in the user's wallet (this is not a transaction, just a signature).

The EIP-712 message will approve the token via EIP-3009 to be pulled from the user by Peanut Protocol.

const { payload, message } = await peanut.makeGaslessDepositPayload({
    address, // address of the user's wallet
    contractVersion, // peanut version. At least 'v4.2'. 
    password, // unique password for the link, can be generated via 'getRandomString' function 
    linkDetails: {
        chainId,
        tokenAmount,
        tokenType, // must be 1 for ERC-20
        tokenAddress,
        tokenDecimals,
    },
})

2. Sign the Message

There should be a method in your wallet API called signTypedData. Use it to sign the message obtained in the previous step.

3. Execute the Deposit

Execute the gasless deposit via Peanut's API.

const { txHash } = await peanut.makeDepositGasless({
    APIKey, // peanut api key
    payload, // payload obtained in step 1
    signature, // signature obtained in step 2
})

And that's it! Congrats! Your user just sent some tokens without paying for gas!

3.2 Advanced. Execute the Tx by Yourself

If you want to execute the gasless deposit via your own relayer instead of using Peanut's. There is a helpful function for you! It computes the to address and calldata (called data).

Simply sign it with your relaying wallet and execute!

const { to, data } = await peanut.prepareGaslessDepositTx({
    payload, // paylaod obtained in step 1
    signature, // signature obtained in step 2
})
EIP-3009