3. Hello, lambda!

In this tutorial, we're going to insert some code into blockchain execution with an evm lambda.

Requirements: You've already created your user account and an organization.

Steps

  1. Create a new canvas using the Create button at the top right of the Canvases table.
  2. Insert an EVM Lambda component using the expansible canvas sidebar at the left of the canvas.
  3. Click the ✏️ icon in the new lambda component to open the integrated development environment (IDE).
  4. In the Add hooks menu, select the Address type. Let's target vitalik.eth: 0xd8da6bf26964af9d7eed9e03e53415d37aa96045. You'll be given an option to input an ABI for this address, but in this case it's an externally owned account (EOA) so it doesn't have an ABI. Just hit Enter to proceed.
  5. Select TransactionFrom. Leave the default checkbox in Post, meaning we'll insert our code after each transaction from vitalik.eth. Toggle on Generate schema to save us some work. Click Add hook.
  1. As soon as you add the hook, a the TransactionFrom schema is automatically generated and populated in the lambda code. Hit the test button and let's run it from 19365540 to 19365541. The test logs will pop open with a record for the transaction from vitalik.eth in block 19355540.

Recap: In this tutorial we hooked on each instance in which vitalik.eth was the sender of a transaction and emitted a record based on an auto-generated and auto-populated schema.

While you're here...

  1. Try testing again but with the block range incremented by one: 19365541 to 19365542. You'll find empty logs from this test because vitalik.eth sent no transactions in that block range.
  2. Within the callback function, postTransactionFrom, type ctx. and view the autocomplete options. All of this data is available within the context of each transaction hook. You can convert some of it to a string and emit it as a separate console log, e.g. simConsoleLog(simToString(ctx.caller)) returns vitalik.eth's address. We'll learn later how to emit this data to persistences and webhooks.

What’s Next