A Peanut Link is a simple URL that uniquely identifies a deposit and allows itself to unlock in the future. Each Link follows the same basic structure shown below.

Copy

<https://peanut.to/claim?c=CHAIN&i=INDEX&v=VERSION&p=KEY>

<aside>

❗️ It is extremely important to securely share a Peanut Link with the intended recipient as anyone with this link can claim the locked funds.

</aside>

When a Link is created, funds that are being sent are deposited into a Peanut Smart Contract. This contract holds the funds until they are unlocked.

Creating a Link

Peanut Links are easily generated and are flexible in the manner in which you create them. You can create a Peanut Link using the following ways:

Regardless of how you create a Peanut Link, all Peanut Links go through the process described below behind the scenes.

https://docs.peanut.to/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FzTzBxCPjO1vcMopco0WK%2Fblobs%2Faf8ZVMPjId9tm8OyE1qG%2Fimage.png&width=768&dpr=4&quality=100&sign=e90ff85c&sv=1

The diagram captures what a Peanut Link goes through behind-the-scenes.

Each time crypto is deposited into a contract a seed is created to protect the funds. This is used to deterministically generate an asymmetric key pair. The public key of which is stored along with the funds in the Peanut Smart Contract.

Storing the public key along with the funds allows a simple pre-shared secret to unlock funds whilst also preventing onchain front running. If the seed was used directly, malicious actors watching the mempool could simply rebroadcast the claim transaction with a higher priority fee and take the funds for themselves.

The crypto being sent along with the public key are stored by calling makeDeposit in the Peanut Smart Contract. The onchain function emits a DepositEvent which contains an index parameter. The index parameter is where the funds will be stored until claimed within the Peanut Smart Contract.

Once the deposit is received, a Link is created. The Link uses the chainId of the chain where the deposit was made, an identifier referencing the Peanut Smart Contract version and the seed used to generate the key pair.

Together all these parts are all that are required to claim funds later.