Skip to content

weaveVM/lambda

Repository files navigation

Synopsis

Lambda (læmdə, Greek: λάμ(β)δα, lám(b)da, λ) is a smartweave execution layer as rollup on top of WeaveVM testnet, more precisely, an MEM implementation. Lambda make use of WeaveVM's DA and Arweave permanent storage (via WeaveVM as proxy) to facilitate highly complex smart contracts beyond EVM and solidty (bytecode machine) limitations.

Build Locally

git clone https://github.com/weavevm/lambda.git

cd lambda

npm install && npm run sequencer

Lambda Terminology

Lambda calculus (λ-calculus) is the foundation of Lazy Evaluation, the programming language theory on which SmartWeave (and thus Lambda) is built. Therefore, we decided to name this rollup "Lambda".

Technical Architecture

Currently, the sequencer is written in JavaScript with NAPI-rs bindings to facilitate a full transition to Rust in the near future.

Data Protocol Design

Lambda follows the data protocol outlined in ERC-7689 (smart blobs) with slight modifications. Most importantly, it shares to the same data structure for ERC-7689 transactions (types 1 and 2).

Data Differences

Data Availability

ERC-7689 describes how to utilize EIP-4844 (blobs) to create a data-computation layer. In contrast, Lambda uses transaction calldata. This difference in data availability allows Lambda to be deployed on any EVM L1s and L2s, while ERC-7689 is limited to EVMs with EIP-4844 implemented, mostly restricted to L1s.

Calldata offers Lambda a "permanent" data availability on the EVM network, while blobs are limited to ~14 days of availability.

Data Archiving Transactions

This section outlines the format used by the lambda sequencer to push data to Arweave. The sequencer interfaces with Arweave using Irys. When indexing data from lambda into Arweave, the following JSON format is utilized to construct the tx data:

{
  "TxId": "L1_txid",
  "Type": "1 or 2",
  "Caller": "tx_caller",
  "Data": "tx_calldata"
}

Lambda Context

The Lambda context is injected by the sequencer during the lazy evaluation of a transaction. It provides a suite of useful APIs that are accessible during execution and the retroactive lazy evaluation:

method description status
lambda.msg.sender return the transaction sender (EOA) supported
lambda.tx.id return the call's transaction id supported

Examples

Contract source code

export async function handle(state, action) {
  const input = action.input;

  if (input.function === "increment") {
    state.counter += 1;
    state.users.push(lambda.msg.sender);
    return { state };
  }
}

Contract initial state

{
  "counter": 0,
  "users": []
}

Lambda Sequencer

Testnet sequencer endpoint: https://lambda.pink

Methods

Transaction Type 1: deploy contract

curl -X POST https://wvm-lambda-0755acbdae90.herokuapp.com/deploy -H "Content-Type: application/json" -d '{"txid":"$CONTRACT_ADDRESS"}'

Transaction Type 2: send interaction

curl -X POST https://wvm-lambda-0755acbdae90.herokuapp.com/transactions -H "Content-Type: application/json" -d '{"txid":"$INTERACTION_TXID"}'

Type Agnostic Method: handles both types 1 and 2 automatically

curl -X POST https://wvm-lambda-0755acbdae90.herokuapp.com/tx -H "Content-Type: application/json" -d '{"txid":"$TXID"}'

For more code examples on how to interact with the Lambda sequencer (deploying contracts, sending interactions, reading state), check the code snippets available in examples.

License

This repository is licensed under the MIT License.