🥜
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
  • Claim Link using EthersV5
  • Claim Link using Signer Agnostic Functions
  1. Integrate
  2. Using the SDK
  3. Claim

Claim Link

Here is how you can claim a link that you have previously created!

This claiming method requires a transaction from your wallet. For a smoother claim experience, take a look at the next section Claim Gasless Link.

Claim Link using EthersV5


import peanut, { getDefaultProvider } from '@squirrel-labs/peanut-sdk'
import { Wallet } from 'ethersv5'

const chainId = '137' // polygon
const mnemonic = 'announce room limb pattern dry unit scale effort smooth jazz weasel alcohol'

async function createLinks(): Promise<string> {
	let wallet = Wallet.fromMnemonic(mnemonic)

	const provider = await getDefaultProvider(chainId)
	wallet = wallet.connect(provider)

    	const link = 'https://peanut.to/claim?c=137&v=v4.3&i=2159&t=sdk#p=pW5awL4lFBY0Fr3C'

	const claimedLinkResponse = await peanut.claimLink({
		structSigner: {
			signer: wallet,
		},
		link,
	})

	console.log(claimedLinkResponse.txHash)
	return (claimedLinkResponse.txHash)
}

createLinks().then((hash) => console.log(hash))

Claim Link using Signer Agnostic Functions

import peanut, { getDefaultProvider } from '@squirrel-labs/peanut-sdk'
import { Wallet } from 'ethersv5'

const chainId = '137' // polygon
const mnemonic = 'announce room limb pattern dry unit scale effort smooth jazz weasel alcohol'

async function createLinks(): Promise<string> {
	let wallet = Wallet.fromMnemonic(mnemonic)
	
	const provider = await getDefaultProvider(chainId)
	wallet = wallet.connect(provider)
	console.log('Wallet address:', wallet.address)
	
	const link = 'https://peanut.to/claim?c=137&v=v4.3&i=2160&t=ui#p=0JObAtHfeDX7HI7K'
	
	const claimedLinkResponse = await peanut.prepareClaimTx({
		recipientAddress: wallet.address,
		link,
	})
	
	const convertedTx = peanut.peanutToEthersV5Tx(claimedLinkResponse)
	
	const tx = await wallet.sendTransaction(convertedTx)
	
	console.log(tx.hash)

	return tx.hash
}

createLinks().then((hash) => console.log(hash))
PreviousClaimNextClaim Gasless Link

Last updated 1 year ago