# Batch Create Links

### Batch Create Links using EthersV5

If you are using EthersV5 as your signer, you can call the `createLinks` function to produce multiple Peanut Links at once.&#x20;

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

const chainId = '11155111' // Sepolia
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 linkDetails = {
            chainId: chainId,
            tokenAmount: 0.001,
            tokenType: 0, // 0 for ether, 1 for erc20, 2 for erc721, 3 for erc1155
            tokenDecimals: 18,
        }
    
    	const createdLinks = await peanut.createLinks({
            structSigner: {
                signer: wallet,
            },
            linkDetails,
            numberOfLinks: 5,
        })
    
        return createdLinks.map((link) => link.link)
}

createLinks().then(() => console.log('Congrats!!'))
```

### Batch Create Links using Signer Agnostic Functions:

You're not using Ethersv5, but some other signing library (viem, web3js, wagmi, inhouse etc)? No problem! You will have to prepare the transactions(s), submit the transaction with your wallet, and use the resulting transaction hash to generate the links. The following code is an example that does not use a particular signer.&#x20;

```javascript
const chainId = '11155111' // Sepolia
const mnemonic = 'announce room limb pattern dry unit scale effort smooth jazz weasel alcohol'

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

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

        const linkDetails = {
            chainId: chainId,
            tokenAmount: 0.001,
            tokenType: 0, // 0 for ether, 1 for erc20, 2 for erc721, 3 for erc1155
            tokenDecimals: 18,
        }

        const numberOfLinks = 2

        const passwords = await Promise.all(
            Array.from({ length: numberOfLinks}, async () =>
                peanut.getRandomString(16)
            )
        )
    
        const preparedTransactions = await peanut.prepareDepositTxs({
            address: wallet.address,
            linkDetails,
            passwords: passwords,
            numberOfLinks: numberOfLinks,
        })
    
        const transactionHashes: string[] = []
    
        for (const unsignedTx of preparedTransactions.unsignedTxs) {
            const convertedTx = peanut.peanutToEthersV5Tx(unsignedTx)
    
            const signedTx = await wallet.sendTransaction(convertedTx)
    
            transactionHashes.push(signedTx.hash)
        }
    
        const { links } = await peanut.getLinksFromTx({
            linkDetails,
            passwords: passwords,
            txHash: transactionHashes[transactionHashes.length - 1],
            
        })
        
        return links
}

createLink().then(() => console.log('Congrats!!'))
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://peanutprotocol.gitbook.io/peanut-protocol-docs-1/integrate/using-the-sdk/create-claimlinks/batch-create-links.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
