API Documentation

Looking for an example on how to implement Merkle roots in your contract? Here’s a guide with our sample root.

Creating a Merkle tree

If you have a list of addresses for an allowlist, you can create a Merkle tree using this endpoint. Any Merkle tree published on Lanyard will be publicly available to any user of Lanyard’s API, including minting interfaces such as Zora or mint.fun.

POST https://lanyard.org/api/v1/tree
// Request body
{
"unhashedLeaves": [
"0x0000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000002"
],
// in general you can omit the two following fields, but if you have specific data
// requirements you can include them to help with indexing
"leafTypeDescriptor": ["address"], // defaults to `["address"]`, can pass other solidity types
"packedEncoding": true // defaults to `true`
}
// Response body
{
"merkleRoot": "0x000000000000000000000000000000000000000000000000000000000000000f"
}

Looking up a Merkle tree

If a Merkle tree has been published to Lanyard, it’s possible to request the entire tree by providing the root. This endpoint will 404 if the tree associated with the root has not been published.

GET https://lanyard.org/api/v1/tree?root={root}
// Response body
{
"unhashedLeaves": [
"0x0000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000002"
],
"leafCount": 2,
// in general you can ignore the two following fields
"leafTypeDescriptor": null, // or an array of solidity types
"packedEncoding": true // a boolean value
}

Getting proof for a value in a Merkle tree

Typically the unhashed leaf value will be an address.

GET https://lanyard.org/api/v1/proof?root={root}&unhashedLeaf={unhashedLeaf}
// Response body
{
"proof": [ // or empty if the unhashed leaf is not in the Merkle tree
"0x0000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000002"
],
"unhashedLeaf": "0x0000000000000000000000000000000000000003" // or null if not in the tree
}

Looking up potential roots for a given proof

A more advanced use but helpful if you just have a proof.

// proof is 0x prefixed, comma separated values
GET https://lanyard.org/api/v1/roots?proof={proof}
// Response body
{
"roots": ["0x0000000000000000000000000000000000000003"] // returns error if not found
}