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
- Create a new canvas using the Create button at the top right of the Canvases table.
- Insert an EVM Lambda component using the expansible canvas sidebar at the left of the canvas.
- Click the ✏️ icon in the new lambda component to open the integrated development environment (IDE).
- 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. - 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.
- 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 from19365540
to19365541
. The test logs will pop open with a record for the transaction from vitalik.eth in block19355540
.
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...
- Try testing again but with the block range incremented by one:
19365541
to19365542
. You'll find empty logs from this test becausevitalik.eth
sent no transactions in that block range. - Within the callback function,
postTransactionFrom
, typectx.
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.
Updated about 1 month ago
What’s Next