logo
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.
plain text
https://peanut.to/claim?c=CHAIN&i=INDEX&v=VERSION&p=KEY
❗️ It is extremely important to securely share a Peanut Link with the intended recipient as anyone with this link can claim the locked funds.
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:
  • Peanut App
  • SDK
  • An integration (e.g. wallet or app)
  • Smart contract
Regardless of how you create a Peanut Link, all Peanut Links go through the process described below behind the scenes.
Image without caption
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.

Claiming Funds Stored by a Link

Similar to the creation process, Links can also be claimed in the same ways via:
  • Peanut App
  • SDK
  • An integration (e.g. wallet or app)
  • Smart contract
The process for claiming funds is much simpler and only requires the information supplied as parameters in the link:
https://peanut.to/claim?c=CHAIN&i=INDEX&v=VERSION&p=KEY
There are four parameters to take note of in a Peanut Link. The following table describes what each of the parameters mean.
Key
Value
Explanation
c
Numerical chain ID of the chain the funds were deposited to
Peanut contracts exist on multiple chains and it's important to know where the funds were sent when the link was created to be able to transfer them to a beneficiary
i
Numerical index
Peanut contracts have numbered storage slots for crypto that has been deposited, this identifier allows the contract to know which slot is being referenced by a claim
v
String version identifier (e.g. v4)
Multiple Peanut contracts can exist in parallel, this identifier maps to a particular contract address which is then used to execute the claim. It must be the same as the contract used to create the link
p
String of seed key
Used to regenerate the key pair used to secure the funds deposited to the peanut contracts
The asymmetric key pair is recreated using the pre-shared seed key. The private key of the key pair is then used to sign the destination address and sent along with the other Peanut Link parameters when calling withdrawDeposit in the Peanut Smart Contract.
Image without caption
The contract verifies the signature of the supplied address both matches the address and originates from the key pair used to create the deposit. If these conditionals pass then the crypto stored in the slot is sent to the beneficiary.

Withdrawing a Link

Peanut Protocol also supports the sender withdrawing funds from the Link. Allowing the sender to withdraw funds serves as a way of recovering funds by the original sender if the link (and key) were to be lost or stolen.
ℹ️ The only address that can recover funds from a Link is the original address creator. The Peanut Team is unable to access or help recover funds.
Currently Links can be withdrawn via:
  • Peanut App
  • SDK (coming soon)
  • Smart Contracts
A user wishing to withdraw funds from a Link should call withdrawDepositSender in the Peanut Smart Contract used to create the link.