Claim Link as Sender (Reclaiming)
Did you lose your link? Did something go wrong when creating the link? Don't worry, a sender can always reclaim their link.
import peanut, { getDefaultProvider } from '@squirrel-labs/peanut-sdk'
import { Wallet } from 'ethersv5'
const chainId = '137' // polygon
const transactionHash = '0x'
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 txReceipt = await peanut.getTxReceiptFromHash(transactionHash, chainId)
const latestContractVersion = peanut.getLatestContractVersion({
chainId: chainId,
type: 'normal',
})
const depositIdx = peanut.getDepositIdxs(txReceipt, chainId, latestContractVersion)
const preparedReclaimtx = await peanut.prepareClaimLinkSenderTx({
chainId: chainId,
depositIndex: depositIdx[0],
contractVersion: latestContractVersion,
})
const convertedTx = peanut.peanutToEthersV5Tx(preparedReclaimtx)
const signedTx = await wallet.sendTransaction(convertedTx)
return signedTx.hash
}
createLinks().then((hash) => console.log(hash))Last updated