Loading video player...
Hello. Hello everyone. I hope uh you can
hear me and see me. Uh if you can drop
just drop in the chat from where are you
tuning from, that'll be highly
appreciated. So I know that you can hear
me and we're going to start in uh in a
minute.
Just going to wait for everyone to to
pop in. So hi everyone. Yeah, so you
know the drill, the usual. uh we will
just uh type in the comments from which
country you're tuning from or city. And
uh the book that you can that you're
seeing now is this one. So I'm going to
paste in the chat the the link to the
book and I'm going to have it uh as a
banner here as well. So this is the only
URL that we're going to need for for
this workshop for this master class.
Sorry. It's going to be a two-hour link
lab masterless. Um the GitHub repository
for this uh example is also available in
the book as well. Just going to if you
scroll a bit down, there it is. This is
the code where everything is hosted. And
these are the prerequisites that we sent
to you prior to install. So if you don't
have anything any of these set up like I
don't know you don't have e or USDC on
on bay or gemini free API key or you
don't have pushover haven't downloaded
pushover app uh please do that now so
you can uh so you can follow uh the the
workshop
okay let's let's start uh with with the
agenda so as you already know my name is
Andre I work as a developer relations
engineer here at Chen Collabs and uh
this u this master class is co-hosted
with Nolan Edwards who is also one of
the developer engineers here at Chen
Clabs and the mastermind behind the code
for today um round of a show. First
we're going to start with the fireside
chat. We're going to be joined by Akar
and Eric. Akar is um V VP of product
chain collabs and Eric is head of
engineering at the Coinbase developer
platform and also one of the co-authors
of the X42 white paper as well. Um after
that after the the fireside chat we're
going to have a hands-on workshop and
we're going to build with these two
technologies CR and X402 and finally
we're going to have a Q&A session where
you can ask any questions you you want.
Uh speaking of questions, you can also
put them uh in the in the chat as well
while the the stream is in the YouTube
chat while the stream is ongoing and the
Nolan will answer them uh or or Zuben
and we'll answer them as well. Um before
we start with the with the uh with the
fireside chat uh just couple of info we
have couple of upcoming events speaking
of Siri. So in January we're going to
have our own Siri boot camp. is going to
be two days long and after that in
February 2026 there will be a series
hackathon. So today two hours in January
two days and then the whole hackathon in
February uh as a as a follow-up without
further ado we're going to start with
the fireside fireside chat. Uh our
speakers today are Akar who is as I said
VP of product to chain clouds. Akar
leads product management for CR which
stands for chain link runtime
environment and he will introduce C and
share some insights for how to leverage
it in your applications. Uh the second
panelist is Eric. He's head of
engineering and cobbased development
platform and as I said one of the
co-authors of the X42 white paper. He
will be introducing X42. So uh I'm going
to just invite now Akar and Eric to the
stage. I'm going to stop sharing my
screen and we are going to we're going
to start with the panel. So I hope you
can hear me guys.
>> You can.
>> Yeah. Set it there.
>> We're going to start with Eric. So as
this is like a very developer focused
event. The majority of audience here are
developers. For developers that are
seeing X42 for the first time today. Can
you briefly explain like what is it as a
as a tech or at a like technical level?
>> Yeah, so uh hopefully everyone in the
audience is familiar with HTTP. Uh what
X42 lets you do is include a payment in
any HTTP request. So as engineers that's
I think probably the most intuitive
explanation where there's no kind of
like other server you need to go and
ping. You're including the payment
directly in the request a client and a
server are already making to each other.
And so this unlocks a whole variety of
of use cases and things you can do.
Inline payment for digital resources or
paying for content if you you know if
you ever seen like a payw wall on you
know some news publisher that could just
be a payment that happens in line when
they respond to you. Um, and
[clears throat] it kind of creates this,
you know, payment channel that's really
native to the internet that's not tied
to a particular token or particular
blockchain. Um, and allows for kind of
the value to move in the same way that
data moves on the internet. And, uh,
this is of course really good for AI
agents. AI agents, uh, I'm sure people
in the room have have, uh, written an
agent before. They're ultimately just a
for loop with an LLM, right? And so the
their programs if you give agents
programmatic ways to pay they get
suddenly significantly better at paying
for stuff.
>> Cool. And yeah as you mentioned like uh
audience is probably familiar with at
least HTTP 40 404 like the most popular
one. Well the most popular one uh status
code but 402 is something that we had
from the beginning of the web and now is
being leveraged by this protocol. um
what originally inspired the creation of
X42? If you can share some insights with
us today.
>> Yeah, for sure. So, it's it's a really
old idea that I think has time has come
and so people have been trying to do
payments on the internet since like the
early 90s and uh I think the so this is
not the first attempt. I'm the I
architect at X42. I designed the X42
protocol, but I took great inspiration
from
the history of attempts on to do
payments on the internet. And I think
the time the reason why the time is now
is that with modern blockchains, you
have open digital native ways to move
money that are, you know, 200 2
millisecond time to settle versus, you
know, 10 minutes. And a lot of these
attempts have been trying to build on
Bitcoin. uh permissionless access where
anyone can participate, any wallet can
make a payment. Uh and you now have AI
as this kind of incumbent where credit
cards are kind of good enough for a lot
of human interactions. There are flaws
of course. You can't really do payments
that are less than 50 cents. You know,
there's acceptance is a whole whole deal
where you can't really serve a global
audience unless there's local payment
processors in in every country in the
world. But it's kind of been good
enough.
But you [clears throat] have now have AI
agents which are this technological
tectonic shift that gives us kind of
permission to re-evaluate how the web
works and how these standards uh that we
use every day and which affect our lives
in so many subtle ways are are commonly
distributed and I think now asic
payments is really the reason on detra
of uh x42 taking off and there being you
know strong attention
for something like this to be possible.
I think in past like the tech wasn't
ready and there wasn't this moment where
cultural shift in the technologies we
use is possible but now the tech is
ready and I think all of us are shifting
how we think about uh the internet and
how we think about technology on a daily
basis as these models continue to
evolve.
>> Cool. Thank you. Thank you for such a
such a good answer. you mentioned uh AI
agents and and at part of your last
answer. Uh as a final question, what
problem around payments for agents does
X42 specifically solve that didn't have
have a clean solution before? What what
are you seeing in the market?
>> There's a few there's definitely a few.
So one is how do you give an agent
access to your credit card in a safe
way? If you just give it your credit
card number and the CVV and the
expiration date, that seems kind of
dangerous as it would just have, you
know, the ability to spend unlimited
money. Wallets are actually extremely
good for segregating funds. And you can
give your agent a wallet, access to a
wallet that is that wallet is o only
dedicated to that agent. And so you put
$20 in, the maximum it can spend is that
$20. And so it's it's really ergonomic
for developers building agents because
you have like by default you know crypto
cryptographically isolated funds. And
then two ease of adoption and ease of
access. You don't need anyone's
permission to build on X42 or to build
on crypto. It's available to anybody in
the world 247 permissionlessly. You
don't need to go register some API key
and have some approved. you can just go
and start building using open source
software today. And then three, I think
that the types of purchases that agents
are going to make are going to look very
different than the types of purchases
that humans make. And so humans, most
credit card transactions we do are
either a subscription or an e-commerce
purchase. There's a very few
uh that don't fall into one of those two
buckets. Maybe purchasing like an ebook
would be an example where you're making
like a $10 transaction to buy a PDF or
something. But the majority of
transactions human do are either
subscription or like e-commerce
and agents I think are not going to want
subscriptions in the same way that
humans do. I think agents want more kind
of one-time access which is more task
oriented rather than con consistent
access. You may, you know, eventually
get to a consistent access model where
you do want to subscribe and get an API
key, but the right now AI agents very
much do tasks that are specific for the
human that they're operating on behalf
of. And what those tasks are is is kind
of wide ranging. And so it's impossible
to know the set of subscriptions that
your agent needs or you build the agent.
And what X42 unlocks is instead of you
having to go and like put your credit
card down and get an API key for 10
different vendors for different sources
of data to add capabilities to your
agent, you can just give your agent a
wallet with a balance and it can pay per
request as it goes and performs tasks
for you. And you can even
programmatically give it a budget where
you can say like, hey, your budget to do
this task is 50 cents. And then it can
go and say like I'd like to purchase you
know this piece of data and this piece
of content and that'll help me that'll
help inform me giving you a better
response or better performance in the
task you've had me do.
>> I see. Thank you. Thank you very much.
Thank you for for joining us and uh
congrats on the launch of the W2 of X42
which just happened recently. I saw that
on Twitter. So that's really really
exciting. Now we're going to move to to
a car. Uh chaining runtime environment
is also something really really new that
we launched recently. Uh so for
developers that are uh new to to to
Siri, can you for a start explain what
what CR is?
>> Yeah, sure. Uh thank you. Thank you for
having me. Uh hi everybody. So I would
say the the simplest form is uh it gives
developers an ability to write uh
workflows that can seamlessly connect
offchain and onchain activities and
operations. Um and these workflows run
in an environment that allows for
verifiability. You know, we like to say
at at the top level, it's an
orchestration layer that allows
developers to build advanced web 3
applications, but at its core, it's just
it's a platform that allows you to write
workflows. Um, these workflows can have
business logic, and they can be written
in Typescript or Go. Um, more languages
uh to follow as we as we kind of iterate
and improve CRA. um but they allow
developers to call unauthenticated
authenticated APIs. They can um read and
write from multiple chains without
having to worry about all the nuances of
what you need to do for a chain thinking
about um you know block sizes, finality.
Um we provide kind of that level of
abstraction that makes sure that you can
guarantee execution there. So that's
really kind of what CRA is. Um the
reason we built it and there's a there's
an interesting self-s serving reason
here. Most of our new products that
chain link builds is actually built on
top of CRA. So there's it's we scratched
our own itch because we realized that
this was a problem that we were facing
building kind of complicated and
advanced applications. But in addition,
when we went to the market and talked to
developers and tried to understand all
the problems that they were having, one
of the core areas was that they were now
starting to build all these applications
that had this level of complexity built
in. And they were having to do a bunch
of off-chain
uh off-chain things and they'd had to
manage all that off-chain
infrastructure. They had to think about
the security. How do I make sure it's
running properly? Um and we we decided
that that was an area that we could help
with. We can kind of provide this server
serverless infrastructure that allows
you to run workflows. You can verify
what's happening and uh and then we can
provide a level of capabilities and
abstraction that allow developers to
move really quickly without having to
get into the nuances and the
nitty-gritty.
>> Uh great. Uh I really really love your
response. And speaking of workflows, uh
you mentioned we're that at least for
now they can be written in Go or
TypeScript. Just FI for the audience,
we're going to we're going to use
TypeScript today. I hope you're all fine
with that. Speaking of the audience
where we have a majority of developers
um why uh why should we build on CR and
what benefits to to developer C can
give? Yeah, I mean why I think it's a
it's a developer platform that is
hopefully going to provide everybody
every developer with uh with faster
velocity and an easier way to kind of
get things built and running as quickly
as possible. Um the advantages I would
say that we provide is we take kind of
this natural tendency to focus on
abstractions where developers spend a
lot of time right so thinking about
chain read and chain right um a lot of
time is spent on figuring out okay how
am I going to actually get the right
level of finality how do I make sure
that the thing that I want written to
chain actually got to chain um I have to
manage all these RPCs or have to go find
the RP PCs to to make sure that I'm
doing the right thing on the right
blockchain. So, we basically remove all
of that. We abstract it away. Don't have
to worry about gas. Don't have to worry
about, you know, integrating with the
different wallets. We kind of provide
that for you as a as a way. Um, and so
that's the value. We help with
consensus. So, one of the things that,
you know, we run into a lot as we're
writing to multiple chains, writing to
um writing or reading from different
sources is how do you come to consensus
on that? and we provide consensus built
into the the workflow. And so I think
there's a lot of value uh and a lot of
points of integrations and we're super
happy that um we're able to work with uh
Coinbase and Eric and team and and make
sure that as developers are building
workflows they can figure out how to get
uh their agents to interact with them
and then have payments associated with
that. I think there's a lot of uh
opportunity to to build build really
great applications over the next year.
>> Cool. Thank you. Thanks so much for for
talking about CR. And now that we've
heard about X42 and CR, we're going to
actually going to deep dive and try to
build a cool use case around these two
technologies. Thanks so much Aar and
Eric for joining us and give a virtual
round of applause in the comments for
our panelists. Uh, thank you. And I'm
going to now uh share share my screen
and we're going to continue.
Um, okay. So, I hope you like that one.
Uh, we wanted to uh to bring the
creators of these two amazing
technologies
uh to to [clears throat] give to give an
intro before we start. Now, speaking of
starting, we're going to do a quick uh
setup sprint, so to say. So if you go to
to this uh page. So workshop chapter
workshop chapter number one setup
sprint. We need to create a C account
and we need to download CR uh to
download and install C cli. So the very
first start is you need to go to
c.chain.link and create an account or
sign in. Uh so if I go over here this is
basically what I need to do. I need to
enter my email address, my role, I'm
developer, and country. I'm going to
accept priv U u uh terms of service. I'm
going to hit continue. You're going to
receive uh 2FA code and you're in. So,
let's let's do that first, shall we? Uh
you can you can uh write down in a chat
in actually in YouTube comments. uh once
uh once you uh perform all of these
steps so so we can we can continue. So
first step is to set up a Siri account.
Uh I hope majority of you have already
uh set it up because it was one of the
prerequisites but just to make sure that
you have it uh because this is uh this
is like a mandatory thing to have if you
want to run this u this uh this demo. Uh
if you have any questions uh or anything
is like not clear or you have issues
with installing the CLI uh feel free to
type in a comment as well. Uh so either
myself or Zuben and can can help you. Uh
once again what's the GitHub link? So
this is the the book that we're seeing.
Uh and I'm going to uh Okay, ready.
Cool. And I'm going to also paste it uh
in the chat. So this URL so you can just
navigate this.
Okay. Once you
create your Siri account, we need to
install the Siri CLI. So depends whether
you are on Mac OS or Linux or and Linux
or Windows. You have uh two options to
install Siri CLI. The first one and
probably the preferable one is automatic
installation. This is the easiest way.
you just need to run this command. So
for me I am uh on a Mac. So what I can
do is I can just run this uh this
command. Uh so if I go here for example
and run this command and hit enter uh
series CLI will be installed. However, I
already have it installed. So I'm not
going to not going to install it. But uh
make sure to to run this command. And
the what we need to see is basically the
valid C version. So we need to we know
we successfully installed Siri CLI if we
run Siri version and we see either 103
or 102
or or something like that. So Siri
version sorry it was without dashes. I'm
going to I'm going to try that. So Siri
version without dashes uh is something
that you need to run. And you can see
here that I'm on version 102. But
however there is an update available so
I can run Siri update after this
workshop to bump to 103 which means that
you'll most likely see 103 here. So once
again Siri version after you run this uh
one of these scripts depends whether
you're on like Mac OS and Linux or
Windows. If something uh is not okay
with the scripts or you prefer to just
manual install uh there there's an
second option with manual installation
and these are the links for either again
Mac OS and Linux or Windows. So again if
I hit this I'm going to I'm going to be
navigated to the official chain
documentation which essentially I need
to download the series CLI from GitHub
releases and just follow the steps here.
It's really easy. I just need to run a
couple of commands and eventually I will
need to run again Siri version to uh to
validate that my installation was
successful. So once you have Siri
version as as one of you already put in
the in the GitHub in YouTube comment
section uh we can we can proceed with
our third step.
So
just just type in a in a YouTube
comments once you have a C version uh
available and whether it's like 103 or
102
I'm going to wait for for like a bit
more. Okay. 103 103 103. Cool, cool,
cool, cool. I'm I'm really glad that uh
automat automatic installation worked.
Um 103 103. Perfect. [clears throat]
Cool. Now that we have Siri uh CLI
installed, uh the last thing that we
need to do is we just need to log in uh
to
so in the first step you
created an account here. You installed
the CLI and now using that CLI you just
need to log in. So the command for that
is to just type Siri login.
And I'm going to type that as well. So
if I do Siri login,
you see how it uh prompted me here. So I
will need to sign in uh with Siri and
log to my to my account. So my I'm using
this um email address
and we can see here that I'm
successfully logged in. So that's pretty
much what what you need need to do as
well. Once you see this screen then we
can proceed with the actual workshop.
So just type in a in a YouTube comment
once you successfully logged in and once
you can see this this screen basically
we're going to wait for a couple more
minutes. Done. Logged in. Logged in.
Success. Thank you guys for confirming.
Cool. Uh I'm really glad that we set
this up cuz this was uh this was the
command everything to set up. Now that
we have Siri CLI pluging completed
successfully. Cool. Um what's possible
with CRI a Siri? Now we can create new
Siri projects or workflows running Siri
in it. We can compile worksho workflows
with CLI. We can tax test workflows
locally with the similar command and
finally we can deploy work workflows uh
once uh they they are ready. So I'm
constantly talking about these
workflows. Workflows are a piece of
offchain code in either go or typescript
that we are going to write to connect
with to connect real world with uh with
smart contracts on any given blockchain.
And CLI
is basically our go-to tool for creating
new workflows, compiling them,
simulating them, and finally deploying
them. Okay, let's let's move on. Now, we
need to I'm going to quickly uh run
through through this section to just
briefly cover what Siri is and what X42
is. and then I'm going to explain to you
how we can combine these two
technologies for for a use case that
we're going to demo today. So as being
said stands for chain link runtime
environment. Uh it's an all-in-one
orchestration layer that unlocks
institutional grade smart contracts data
connected compliance ready privacy
preserving and interoperable across
blockchains and existing systems. Uh
there are a couple of key concepts that
you need to to learn today. Uh the first
one are workflows. So workflows are
building blocks of CR. Again workflows
are piece of offchain code that we are
going to develop today and uh we're
going to use uh either Go or TypeScript.
Today we're using TypeScript uh using
this uh these two uh using Siri SDK in
Go and TypeScript. Then we're going to
use Siri CLI to compile these workflows
into was binaries and simulate them
locally before deployment hopefully. So
important thing to mention is that a
single workflow can be used with
multiple trains like you can uh reuse
them uh that each workflow is
orchestrated by a workflow dawn that
monitors for triggers and coordinates
execution. the same technology behind be
behind all of the chaining services are
you are familiar with already. Dons dawn
again stands for decentralized oracle
network. The workflow can invoke
specialized capability dons um
capabilities we're going to mention them
afterwards are like building blocks of
workflows and um during execution each
node in a don performs the requested
task independently. So in their own
isolated environment, they're going to
perform the task and then report the
final result to the rest of the network
using peer-to-peer protocol and then all
the nodes in a don needs to come to a
consensus. So all the results are then
cryptographically verified and
aggregated via bison fold tolerant
consensus protocol. The cool thing about
CR is also that you can change proh
consensus rules but more on that later.
So these are workflows. Then we have
capabilities. So as a second thing that
we need to learn today are capabilities.
Capabilities are modular decentralized
services that performs specific task and
each capability is powered by its own
independent DO or decentralized Oracle
network which is optimized specifically
for that task. So you basically develop
workflows using capabilities as a
building blocks kind of like a Lego
bricks. So currently Siri has the
following capabilities triggers. Um so
these are the event sources that start
your workflow execution can be a chronic
trigger. So every 30 minutes or whatever
can be HTTP trigger. We are going to
leverage that one. So that means that
you uh you got the HTTP 402 for example
uh as a as a as a callback and that is a
trigger for the workflow to execute. And
we have log triggers which is
essentially you monitor uh specific
events from a specific contracts on a on
a various different chains all at once
and whenever one of those events get
emitted then that's a trigger for your
workflow to execute. Uh then speaking of
other capabilities, there is an HTTP one
which essentially allows us to fetch and
post data from external APIs with the
central consensus. So we can create HTTP
put, post, get requests, etc. So
everything with everything around HTTP
is possible kind of like chaining
functions but like much much better. So
if you're familiar with functions, Siri
should be easy for you. And also if
you're building with functions, I highly
recommend you to switch to Siri because
it's much much more powerful. And there
is also EVM read and write which
essentially are capabilities for
interacting with smart contracts on EVM
compatible uh blockchains. So read and
write are self-explanatory. Right. Um
this is the link to the docs if you want
to learn more. Now that we understand
that we understood hopefully what Siri
is and what Siri workflows and what Siri
capabilities are uh what we can do with
Siri. So again, blockchain interactions,
read, write to blockchains, multiple
chains all at once, monitor events from
uh from uh different smart contracts
from different uh blockchains all at
once, then interacting with external
data and APIs uh from calling APIs to
having a custom consensus aggregation.
So you can use median or you can use all
all the uh all the nodes needs to report
the same value or you you will see in
the docs there's like a bunch of
different consensus consensuses that you
can apply uh from data transformation
you can just use we are going to use
typescript so you can just have like a
helper typescript function for whatever
purpose and you can uh import uh mpm
packages from typescript and then have
some kind of computation as part of your
workflow etc etc. then automation
scheduling because again you can have
chron triggers uh you can have event
triggers with conditional logic so you
just set everything up and um just run
run the the Siri in the background uh
which which for part of this workshop
we're going to do as well and some
advanced capabilities like secrets
management totally safe to to paste API
keys or secrets because of the sharding
between nodes in the dawn you have
robust error handling uh log logging,
monitoring like it's a fully production
ready um um ready product. The the final
thing that you need to understand is
this trigger and callback model. So this
is like a mental model for you and this
this is how we write CRA workflows. So
workflows combine triggers and
callbacks. So you have a trigger that
can be as I said chrome trigger, HTTP
trigger, EVM log trigger then whenever
that that trigger gets triggered like
for example this one will fire every 10
minutes the the fa the callback function
needs to to run. Uh here it's just on
trigger that's the name and it doesn't
do anything. U your business logic
actually goes here but this is how uh
how workflows are uh are triggered. So
finally uh trigger and call back are
kind of glue with [clears throat] these
Siri handlers. So this function Siri
handler uh glue trigger and callback
function. And you will see that shortly
that the main function of Siri does
nothing but only returns the array of
these Siri handlers because you can have
multiple multiple triggers and callback
functions as part of the same workflow.
So in um a main function, we're just
going to return the array of handlers
which again handler glue series trigger
with the call back function. So this is
probably the most important thing to
understand and if you have any questions
about this or anything else but
specifically about this please drop them
in the chat. Now speaking of consensus,
um Siri comes with a predefined built-in
consensus and um it's really
powerful thing about uh consensus is
that every capability execution
automatically includes a consensus. Uh
that means that when your workflow
invokes a capability like fetching a
data from API or reading a reading from
a blockchain uh multiple independent
nodes perform the operation uh and then
their results are validated and
aggregated through BFD consensus
ensuring a single verified outcome. What
does that mean? That means that if my
workflow wants to read a price from a
changing price feed of BTC in terms of
USD or something like that uh every
single node will independently call that
uh smart contract that view function of
a smart contract and report the the
value they got and then each single node
in a don will need to reach a consensus
on on that final price. Now with this uh
with this consensus specifically we can
actually use the consensus rule which
says
every single node needs to report the
exact same price otherwise we don't have
a consensus. Sometimes that's not
possible. Sometimes you're going to use
median. For example, if you ping an
that's that's a silly example, but if
you ping API ping API endpoint that
generates a random number uh obviously
uh in in a range obviously you you will
get different results. So that's
probably not the the best use case for
for Siri but just as a as an example at
that point you cannot have a consensus
where every single node needs to report
the same same price. So and you will see
in the docs there are like uh more and
more different types of consensuses
available. Finally with Siri CLI as I
said in a previous uh previous u page
you can compile workflows simulate
workflows and eventually deploy them. So
CR workflow simulate is the command
alerts is just the name of the of the
workflow we're going to build today. But
this is where your workflow name will
will go and the simulator will again
compile your workflow to wasn't uh
prompt you to select the trigger if if
uh if applicable execute the workflow
locally and even though it's executed
locally it will still make real calls to
APIs and blockchain. So if you make a
chain write transaction the transaction
will actually will will be visible on a
blockchain and on a blockchain explorer.
So just FYI
um this was Siri. So once again key
concepts workflows piece of code that
we're that we're uh developing in titrip
for go capabilities building blocks of
workflows
um trigger and callback model basically
using Siri handlers we we glue trigger
and a callback function together uh and
this is how we invoke workflows and we
are using Siri CLI to compile simulate
and eventually deploy workflows.
Now that we covered the Now that we
covered what Siri is, let's let's cover
what X42 is as well. You heard from Eric
uh during the during the fire chat um
which problems X42 [clears throat]
solves and what inspired them uh to to
to create it. Uh and I can share you
even the the the link to the to the
white paper of X42. It's like 15ish
pages [clears throat] long. It's not
it's not that long, but essentially X42
is Coinbase standard for machine
to-achine payments. Eric mentioned a lot
of uh AI edge agents during his during
his pan panel and essentially that's a
microp payment protocol that enables
pay-per call API access and by by
default it's going to be usually that's
0.01
USDC.
uh X42 the core idea it activates the
old HTTP 402 payment required. So you
can see here maybe you you are familiar
with 404 like when you ping and certain
API endpoint uh you can receive like 40
error 404 like not found. This
essentially is a status code of of HTTP
or you can receive okay this is this is
the one that we usually receive. So when
everything's successfully executed,
there is the okay uh okay status code
and here is the list of all status codes
and these dates basically to the
beginning of the web. So this is all
embedded in HTTP protocol itself and one
of the status codes uh is 402 which is a
payment required status code. This is a
client error response status code. Uh,
and it's basically, as you can see here,
reserved for future use. So, this status
code existed, but never really utilized
and used since the days of early web.
Now, if we go back to our book,
uh, as as I mentioned, X 402 payment
require status code was marked as
reserved for future use. Uh but it never
really took off because web had no
native programmable money layer. Um the
payments happened in PayPal or credit
cards or layers that are abstract
abstracted from the from the protocol
itself. But now with blockchains and
stable coins, the technology has finally
caught up and we can again use 402
payment require um status status code.
Uh imagine that with imagine like as
part of the S SMTP you send protocol you
send an email and you also send like uh
some amount of stable coins or whatever
like directly embedded in a protocol. So
the this is what X42 is about. How X42
works essentially uh there is a server
uh that needs to communicate with the
facilitator. facilitator is uh
Coinbase's uh component which
essentially needs to settle uh this
transaction on chain on any given
blockchain. So imagine you're
interacting with with a server. So
you're having like here we're we're uh
running HTTP get request to the alerts
endpoint and server responded with 402
pay status code payment required. Then
on a client side we're going to create a
payment authorization using EAP721.
EAP71 is basically um Ethereum's EAP to
sign transactions. So we can have like
our own signatures a signature and what
we are going to uh we're going to send
back to server is request pl plus this
x- payment u header. Then the server
will uh using the middleware function.
You will see how that looks in a minute.
Uh ping the verify endpoint of the
facilitator. uh facilitator at that
point will try to settle this onchain by
basically submitting a transaction with
this EAP71 signature to USDC contract to
any given blockchain. In our case,
that's going to be [snorts]
uh that's going to be uh a base Solia
test net and facilitator will then
return a settlement confir confirmation
to the server which then we need to talk
to us as a client with uh status 200
which is okay. It's all good and X
payment response header. Now, if we're
going to deep dive into the code, we can
see here that this payment middleware,
it's a built-in function of X42
essentially uh pings the verify endpoint
of facil facilitator. And here we can
see this scheme. So, we're paying 0.01
USDC and the receiver is some some some
address. Um after that as a callback we
once payment is validated uh then we can
do whatever that's that's our our logic
on the client side we're essentially
making get or post requests to our own
server. So x42 fetch is a function that
pings this alerts endpoint on our server
side uh with uh with um uh with a
certain uh certain methods. Uh here this
is like a little preview but we are
going to basically monitor uh if the
price of bitcoin is greater than uh
$60,000. So this is what this is what
our body looks like and then also we
need to provide our private key and
facilitate UR URL as part of this wallet
header. So key benefits of X42 is that
there are there is no API keys payment
is the authorization to use the alerts
endpoint. uh you pay per usage so no
subscriptions once you need it then
that's when you're paying
cryptographically proof so payments are
verified on chains with the AP71
signatures instant settlement like you
don't need to wait for as Eric said like
10 plus minutes or whatever or even days
you instantly sell this on blockchain
and it's uh pricing is transparent
because it's on blockchain how these two
technologies work together and what we
are going to build today uh we're going
to build a price alert system as I said,
"We're going to uh we're going to
monitor if the price of Bitcoin is
greater than $60,000. And if yes, we
want to receive uh notification on our
phone that the that the price uh is
greater than than 60 uh K. Uh that's
like it's going to look something like
this. You see notification. So this is
what we are trying to achieve today to
eventually uh receive this notification.
Uh how we're going to do that? Well,
we're going to spin up a fully automated
L&M server. So this server is going to
act as our AI agent and we're going to
prompt it with uh with normal regular
language. We're going to just type alert
me when BTC is greater than $60,000 and
that's it. our own server which is
powered by Google Gemini uh will will uh
handle uh all for us. So we're it's
going to parse this natural language
extract conditions payment gate. So it
will be smart enough to create uh this
call so to put body with the conditions
[clears throat] to put these conditions
in a body to to embed 0.01 01 USDC to
talk talked with the X42 uh middleware
etc. Then uh once the X42 settlement uh
once the X42 payment is settled uh we're
going to receive an HTTP status code and
that's going to be our trigger. So again
uh Siri can have HTTP triggers. So this
trigger will trigger this Siri workflow
which should receive roller data, encode
API parameters, generate your report and
essentially write to rule registry
contract. A rule registry contract uh is
uh available here and as a next step
we're going to just deploy it from remix
but essentially a rule register contract
will have certain rules created. This is
the event uh store them in a mapping
like this. And this is going to be our
role. We're going to have a unique ID.
Assets going to be bitcoin. Condition is
going to be greater than 60,000 greater
than target price USD will be 60,000.
And we are going to have a time step. So
after that we can monitor uh a specific
rule uh and subscribe to it. But more on
that later. [snorts] This area workflow
will also create an onchain transaction
to rule register contract which is
already deployed to base sepoleia. Now
uh when you write uh when you invoke
chain write capability with CR uh CR by
default will look for a certain function
um which is process report. So when you
write smart contracts just keep in mind
that similarly to chainic automation or
chaining functions or even VRF we we
have some kind of receiver template here
comes from coming from uh CR. So our
contract needs to inherit this receive
receiver templ template which
essentially just forced us to gen uh to
write the logic for this process report
function because this is the function
that's going to be called by the C uh
done uh when we invoke chain write
capability. So here is our logic where
essentially we're going to call the
write rule function that I'll already
show you up here.
Uh once we do that, that's it. So we we
uh generate a new alert rule. We store
it in a smart contract and that's that's
what we're going to do only once. So
we're going to just only once create
this transaction and interact with X42,
etc. This contract also has a nice view
function to get a single rule or to get
all rules. So by by having this function
that gets all the rules for us and it's
a view function so does it does not cost
any gas for us we can monitor this
contract for new rules constantly. So as
a second part of this uh of this
workshop, we're going to set up an
hourly Siri crown trigger that will uh
that's going to be another workflow
that's going to monitor this contract
that's going to also read prices from
training price feeds monitor this
contract. So read all the rules from a
contract various conditions and if
everything's all right. So if condition
is um um like our condition is going to
be bitcoin greater than 60,000 as I
mentioned if that's that's really the
case then it's going to again send a
push notification to our mobile phone as
I showed to you previously. So make sure
to install this app if you want to see
the notification live at the end of the
workshop.
So the complete flow is alert creation.
So we're going to spin up a server.
We're going to type alert me when BTC is
greater than 60,000. LM will parse this
input. We're going to handle the X42
payments. Siri will trigger HTTP trigger
to write the to trigger the workflow
that's going to write a new rule to
blockchain in and then that's going to
just be one time setup. And then in
phase two, we're going to have another
Siri workflow to constantly monitor
every hour for for new rules that's
going to constantly fetch new prices of
these three assets. So, Bitcoin,
Ethereum and link in terms of USD and uh
and then for each evaluate condition and
for each rule if the condition is met
met send the pushover notification so
you can receive the notification on your
mobile device. Uh and this is the the
mermaid diagram for what we're going to
build today.
uh before we start with with building
the before we start with running the
example uh again you can see the whole
code over here and this is the this is
the rule registry contract you can also
find it here but we're we'll have like a
link to deploy it from remix directly so
you can uh you can learn more about this
contract itself and in the C uh in the C
uh directory there is this alerts
uh alerts folder which is basically a
folder consists of all the files uh
needed for a workflow on the server
directory we have um LLM powered server
that interacts with X42 protocol now
instead of like
uh instead of like building this from
scratch what I'm going to show you is
how you can start your own Siri project
is going to be much simpler than this
one but the idea is to have a building
blocks for your progressive journey. So
we we already have Siri CLI in it. So if
you want to create a new project, you're
going to type Siri in it command and hit
and hit enter. What I'm going to do is
I'm going to just cd to desktop and then
I'm going to run Siri in it. Once I run
Siri init,
uh it will ask me to for a project name.
uh if I type uh my name or whatever
that's going to be the name of the
project. If I just leave it empty and
hit enter, it will use my project as a
default. So this is going to be uh so
it's going to create a new directory
with all the C files in it. Then uh I
need to select which language I'm going
to use, Golang or TypeScript. As we
said, we're going to use TypeScript. So
I'm going to just select TypeScript.
uh then I can start with a template from
either a hello world which is the most
basic one with a little a little as
possible code or I can start with a
custom data fit which I can basically uh
have a fully proof of reserve workflow
so to say I'm going to start with the
hello world the basic one and my
workflow I'm just going to use for the
workflow name the default my workflow
name so I'm just going to hit enter
so now I have a couple of next steps
first of I need to CD into my project.
So if I run this command, I I'll see all
the all the directories and fold folders
I have. Then as one of the
prerequisites, we make we told you to
make sure you have bun installed. So
what I need to do is because this is a
TypeScript workflow, I need to just
install bun install my workflow so I can
install all the dependencies. So I'm
going to just run bun install
um my my workflow and before simulating
it which is a last step I'm going to
open this in my code editor.
So I hope you can see this. Let's do it
like this.
Uh let's put this aside.
Let's close this and let's zoom this a
bit. So this is the code for a simple
Siri project. Uh there is these uh
project YAML and secrets Yml files. For
project YML uh staging settings is uh
something that we are going to use for
local simulations and production
settings are actual config data for
production. By default, we have Ethereum
tested sepoleia details set here, but
we're going to add base sepoleia later.
Inside my workflow directory, there are
a couple of folders, a couple of files,
sorry. The main TS file is the actual
code that we are going to run that we're
going to develop and run later. So as I
told to you
this main function is just returning
this init workflow and init workflow
does nothing but as I said to you
returns an array of Siri handlers. So
again Siri handler is like a glue
between a trigger and the callback
function. So what we did here is that uh
we are creating a new capability the
chron one and it's going to
uh so I can put here like syntax for
every 10 minutes or whatever or it's
going to just uh grab the value of the
schedule from this config uh config
file. So config schedule and it's
basically this one. So this mean every
30 seconds and this is the minimal by
the way for sur. So again config staging
is for local simulations. Config
production is for actual production. So
this thing is going to run every 30
seconds and every 30 seconds as a
callback it will call this on trigger
function which does nothing but console
logging hello world and returning hello
world. So this is this is pretty much
it. Also there is this workflow YAML
file that for now you don't need to to
to do just know that it exists because
for some capabilities like trained right
you will uh you will you will maybe uh
update it but for now just know that it
exists. So as we can see here in this 30
lines of code what we are doing is
returning an array of handlers of one
handler actually which is uh trigger
chrome trigger on every 30 seconds uh
that we're going to call the enchrome
trigger uh function. So if I type now
Siri workflow simulate and then my
workflow
we should be able to see the simulation
results and here they are. So user log
so on line 8 we see that we are console
logging this text hello world workflow
trigger. So we can see here as a user
log hello workflow trigger. Uh we can
see the actual simulation result which
is what was returned from the callback
function and a couple of details about
the simulation process.
So
let's go back to the book now.
Um yeah project structure we cover that
key files we explain those to you. So
project YAML workflow YAML config
staging production and main ts and I
also explained to you what the runner
pattern is and this is the crown
workflow. Uh we we saw all of that.
Cool. We created our first workflow.
Congrats. Now let's build on top of it.
uh as you as you remember we are going
to uh fetch prices in our example from
Bitcoin in terms of USDC eat in terms of
USDC and link in terms of USDC price
fits. So in order to do that we need to
add EVM read capability. So what I'm
going to do now is I'm going to just
copy this whole code over here and uh
and add it to the to the new project I
created. So I'm going to replace this 30
lines of code with this 100 lines of
code. So what do we have here? We have a
config again with schedule and also
array of EVMS. So this EVM config object
just uh has chain selector name. That
means that whatever is defined in this
config needs to exist in config staging
as well here. So we can see here that
config staging at least for now only
have has schedule. So we need to add
EVMS. And if you go back to the book,
you should be able to see this part. So
update config. So we're just going to
add an array of EVMS. Or I can just copy
the whole thing. It's even easier. So
again, config comes from config.staging
because I'm doing local simulations. I'm
going to just paste all that here. And
that's it.
In order to be able to to read uh any
from blockchain from any smart contract,
we need to know which function we're
going to call. So for that, we need AI.
Um we're going to just call the latest
round function. So for simplicity
reasons, we just exported this that tiny
piece of chaining price with AI only
with only that function. Uh so we can we
can call the latest round data view
function afterwards. Inputs and outputs
are defined here. This is something that
you you should already be familiar with.
We're going to look essentially uh to
the answer uh to the answer parameter.
If I go down, scroll down, we can see
that main function remained unchanged.
That init workflow function remained
unchanged. So unchanged. So what we're
going to do is again have a chron
trigger with the same schedule and on
chron trigger instead of uh logging
hello world will do something more
useful. So first of all it will g the
config EVM config from config staging.
So the first array of these EVMS so this
object then uh this is the series
specific syntax we need to get the
network. So this is in typescript how
you how you write that code. So you need
to provide chain family um chain
selector and whether it's test net or
not. Uh then we're going to invoke
invoke EVM client capability
with this chain selector passed as a as
an argument. And here what we're
basically doing is now preparing our
call data for actual function call. So
this is VH specific syntax where you
just provide latest round data as a
function from this API that you want to
call and essentially there is the actual
contract call where you call the
contract from AVM client u this is the
address of bitcoin in terms of USD feed
on basolia and we are providing uh this
this call data so we're calling the
latest round data function on this
address using the last finalized block
number as a block number finally once we
are waiting If we wait for this result
to come back, we're going to have the
price data uh here after we decode the
function result uh based on the API
itself. And finally, what we're going to
do here is just console log the BTC
price. Now, what what we saw here is
that we are interacting with BTC uh USD
feed on Basoleia. That means that we
need to update the staging settings,
right? So, I also added here. So project
YAML project YAML we need to include
another RPC. So
chain name is going to be
Ethereum Sapoleia Ethereum test netia
base one. So this is the the actual name
that Siri is looking for. So I'm going
to do that and we need to provide the
actual URL. Uh for URL I'm going to just
grab it from the from the book. uh or I
can even grab it from from our own um
example. So if you have here we can use
the official one. So sepoleia.
Okay.
And you can see here that we're using
local simulation instead of staging. So
we can do that as well if in inv uh you
set up the the Siri target to something
apart from staging settings can be local
simulation as well. So this is how it's
going to trigger. So you can have
multiple different environments. It's
not that just that you have staging
settings and production settings. You
have like a 100 environments. It doesn't
matter really. Okay. Now that I provided
our URL and the name of the uh of the
chain, I should hopefully be able to run
this command one more time and to
simulate this workflow one more time. So
the command is again Siri workflow
simulate, but now we have a different
function that's going to be executed. So
here again simulator got initialized.
We're still using chroner. This is our
user log. So as you can see
down here runtime log this is how we
cons loging stuff in C. This is our log.
So we now have like BTC prized
[clears throat]
to to fix with two decimals and we're
returning the actual price data. So the
actual value from a smart contract. So
you know that with chaining price uh you
you receive like a raw value of the
price and then based of the decimals uh
value of the certain feed you need to
convert then in solidity or any other
language uh to have um something like
this. So we can see here that the
current price of bitcoin is above
$87,000.
So our trigger with 60,000 should should
work fine. Uh so this is how we can uh
read from uh from um from blockchain.
Another building block that we are going
to use is how we can read from multiple
values from contracts because I want to
read from I want to get all the rules
right. So it's really simple. You just
provide that function part of API for
that function and again create a call
data again call it and decode function
result but as a rule as an array. So
you're just going to provide that uh
that uh that type script type. It's
really it's really simple. So I'm not
just going to do that in the interest of
time. Then as a step three we need EVM
write because at one point we need to
write our own rule after a successful
successful X42 pay and settlement we
need to register new rule on chain. So
to to do that uh we use something called
two-step pattern and call for this thing
is available HTTP callback.ts file. So
if you go here, you can see with nice
formatting how you can uh write to a
smart contract. But essentially um
actually I'm going to do that as well
because I don't have formatting here.
But essentially what we are having here
is again if I go back to the uh um back
to the on HTTP trigger function. So
where it is? Yeah, this is the on HTTP
trigger function. So this is the
callback function that we want to later
glue as a handler with the HP trigger.
Um we are essentially again having an
input data again get network. So same
the same syntax as for reading from
chain again getting an ADM client. Um
this is the just the alert object that
we want to want to pass and
again we are preparing the the the call
data.
So the only difference is instead of
reading we are calling the actual
function that that uh is going to update
the state on a on a blockchain. So this
is again v specific syntax as as we can
see here actually this is the response
as we can see here we're calling the
write report function this is the
receiver the our contract that we're
going to call this is the report that
we're going to pass and uh you can set
some gas limit if you want and instead
of just reading the result like when we
read from from a smart contract here
we're going to wait for a transaction
status because we are updating changing
the states state on the blockchain. And
once we have that, we can um simply
console log the transaction because uh
this function won't return anything
useful for us to to v visualize. Um why
two steps? Well, first we need to
generate report. We need to crypto
cryptographically sign it uh so that the
contract can verify it really came from
us. And then we need to actually submit
the signed report on chain by executing
the write report function. As I said,
this pattern ensures that we're data
integrity and allows contract to verify
authenticity. And as I mentioned,
contract implements RC template. So
whenever you write whenever you want to
uh invoke chain write capability that
smart contract that needs to be uh
written to needs to as I mentioned here
implement this receiver template um
interface which essentially just forced
you to have a process report function
implemented. That's it because this is
the the function that's uh going to be
called by the C redons
workflow simulation result. Hello world.
Nice. Congrats. That's what we want to
to see. [clears throat]
Uh okay. Yeah. Then we will need a HTTP
trigger for our uh for our use case
because we're receiving external data.
So uh that code is also used in HTTP
callback and main TS functions. So in
HTTP callback function we saw the HTTP
trigger function logic implementation
that uh invokes the chain write
capability. However, we decided here to
glue it with HTTP trigger. So we can see
here now we have two handlers right two
capabilities
and the actual on HTTP trigger function
that's going to be executed as a
callback will simply in our example uh
uh just re u just console log the input
data that we're going to that we're
going to pass. So what I'm going to do
now is I'm going to extend our current
example. So let's go here. We need const
HTTP uh new capability for HTTP and we
need another handler. So we have this
one, but we're going to also use another
one. As I said, we can use multiple
handlers and it's now we have these red
squigglies because we haven't
implemented on HTTP trigger. So
I'm just going to add this function as
well.
here and with tabs just import these two
uh payloads and the codejson functions.
So I can now provide a payload input.
We'll see uh what's that and just
console logic because in our actual
workflow we're going to extract this
alert data and code as API parameters
generate Siri reports and write the rule
uh to a rule register contract. So this
is just a quick simulation. So why is
this important? Because now we have
array of two handlers. So if when I run
Siri workflow simulate my workflow,
something interesting is going to
happen. I'm going to be
uh I have a I have an error. Sorry about
this.
Um
I'm [clears throat] lacking one bracket.
Let's see now.
So the interesting thing should happen.
Yeah. So we can see here that workflow
simulation is ready. But we need to
select the trigger because we have a
crown trigger and HTTP trigger and we're
doing a local simulation. So in order to
simulate this, we need to actually
select the trigger. And because we're
testing the HTTP trigger now, it's
number two that I need to enter. So
number two, hit enter. And I need to now
provide this input to an HTTP trigger.
Uh I'm going to grab this manual uh
manually created one, which is a dummy
one. Uh but as we can see here, um yeah,
console log here, we received this
input. This is what I provided as like a
manual hard-coded thing. This is
something that we're going to receive
from our LLM server and the return value
of this function is success. So we we
got success here in simulation.
[gasps and sighs]
Uh finally as a step five we will need
to make some external calls. Um that's
that code for that is located in chron
callback ts function which essentially
is important for our pushover
notifications.
Uh so I'm not going to run this now but
essentially this is the code. Let's go
to chron callback so we can have a
better
better formatting.
So here uh we have uh AIS helpers and um
where is this? One second. This is where
we're getting all the rules. But I'm
looking for the push notification
uh code. Yeah, here we go. pushover
notification. So here I'm going to
interact with API endpoint of pushover
uh pushover notification system uh to
send a push notification to your uh to
your phone. But you need to have that
app installed, right? And this is just
the code that that we took from from
their their docs. However, this is the
syntax for making HTTP post requests.
What I'm trying to say here is that with
send request uh with CR you can make
post uh put post get and other HTTP uh
requests
for whatever reason of course.
Um speaking of HTTP calls uh the
there is like two things that you need
to be aware of. Let's say that we're
again with notifications.
uh let's say that we have like 15 nodes
in a in a dawn. Uh we said that each
single node in a dawn uh will execute
the the code in their own isolated
environment and provide the end result
to the rest of the node to reach a
consensus. In our example that will be
like to have a successfully send a push
notification. So they will all u uh so
all nodes in a don needs to u needs to
send an uh needs to have that um that uh
result of the computation. Similarly to
reading a price data for example, we we
will expect from all nodes to to read to
read the same value from a from a smart
contract. And as I said there is a
consensus for that where which we
basically tell the nodes in the DOM that
every single node needs to report the
same actual the same value otherwise uh
otherwise uh there is no consensus and
in CR that's called consensus identical
aggregation. So if I search for
consensus
identical uh aggregation
uh we can see here that when I'm
creating a post request to post pushover
data to send a notification I'm
expecting all of the nodes to execute to
execute uh to receive the uh the same uh
result of a function.
which essentially is uh that there was
no no errors. However,
what does not make sense that if we have
15 nodes in a dawn, we shouldn't receive
50 notifications. We we don't want to
spam the end user with all of these
notifications. What we are looking for
is to just send one. So to do that in CR
we have something called cache for HTTP
calls. So and we have something called
cache settings
cache settings.
So again post request to pushover URL to
send a push notification.
However there is cache settings. What
does that mean? because every single
node in a DOM will execute this code. If
cache settings are set to true and max
age in this example is set to 60
seconds,
the first node in the Dawn will uh will
need to send the push notification. It
will check the cache because there is
cache and see if anything's written
there because he's because that node is
the very first one cache is empty. So
that node will send a push notification
but then because store is set to true it
will store in cache that that node
particularly send a push notification.
Then the next node in the dawn will try
to send the push notification but again
we'll take a look at the cache. It will
see that the notification was already
sent. So it will just going to skip with
the actual uh actual post request and
then all the next nodes in the non will
check for cache see okay it's uh
notification was sent I'm not going to
I'm not going to send it and that's it
max age is 60 seconds so that means that
anything written in cache that's older
than 60 seconds is not not valid so I'm
going to in theory send a new
notification afterward words, but
execution of this workflow will will
last seconds max, even even less. Uh,
but that's that's also useful if
something is already there in cache from
from previous workflows that can be days
old.
Um, okay. As a as a step number six, we
need to connect X42 server to Siri.
That's our LM power server. Now that we
understood hopefully all of the Siri
capabilities needed for this workshop
and what I explained to you now with
these five steps are only capabilities
needed for this work workflow. What I
haven't show you is bunch of other
capabilities that we haven't used. But
if you go to our docs you will see all
of them because Siri is really really
powerful. So for these two hours at
least I didn't want to bomb you with all
the capabilities. We are uh we are going
to do that in in January when we have
two days. So we're going to cover all
the capabilities then hopefully uh with
X2 on the server side we just need to
protect our payments. So we're going to
have this alerts endpoint. The code is
in SRC server src serverts
and uh this payment middleware this
payment middleware function that comes
from x42 is their their built-in
function that interacts with the verify
endpoint of the facilitator that will
essentially u settle hopefully uh settle
the
the the payment on basipalia for us uh
0.1 0.01 USDC.
Uh so that's why we have this syntax
where we're posting to alerts with uh
with all of this uh these details like
network and price but calling the
paymentware middleware will essentially
uh interact with the verify endpoint of
this facilitator and the funds will be
sent to to whatever this address is.
Um
and then we'll have like a alert
endpoint handler as well. So
afterwards when we are going to monitor
for price changing uh we we want to uh
we want to trigger the Siri workflow to
send push notifications. So that's why
we have uh this this type of this type
[clears throat] of code uh over here on
the client side which again is going to
be handlered by our
AI lm powered server there's just this
x42 client.ts file where there is um
again making a post request that BTC is
greater than one 60,000 to our own uh
server that's going to be run on local
host 3000. So this is the very first
step where we are initiating the payment
that's going to be settled uh here by
this payment no function hopefully. So
this is the whole flow. Uh I'm going to
demo it in a minute. Uh these are the
capabilities that we we learned about
today and that we're going to use. So
again chron trigger, EVM read, EVM
write, HTTP trigger, HTTP client and X42
integration. Uh and now
let's let's start with a hands-on
exercise and let's finally get that push
notification.
So workflow structure is like this. Uh
so code is located in main.ts HTTP
callback chronback types and config. If
you have trouble understanding any of
these pieces of code from here, just go
back to chapter 3 to to uh to to recap
what we covered.
As the first step, we will need to
deploy this rule register contract. So
if you click of this on this link, it
will open the same URL I have here where
remix is preloaded with this contract
role registry. So you can so you can use
it uh as is. If you don't want to deploy
it or you don't have enough funds or
whatever, we also deployed uh the same
contract on this address. So you can use
that one as well. However, keep in mind
that this demo contract may be populate
with with multiple alerts from other
developers. So that might uh might
affect you. So
to deploy this contract I first need to
compile it and I need to go here. Uh I
need to connect with
injected provider MetaMask
and I need to make sure that I'm on
base.
So basia test net I not a huge fan of
this new MetaMask UX. So I'm going to
quickly verify that. that base polia uh
chain ID uh uh uh uh uh uh
okay [clears throat]
so
okay I'm on optimism okay cool let's
switch to bapoleia if this is possible
um count one
pipoleia
uh let's see if I can
if I can
disconnect this
uh
base.
Okay, it changed. Oh my god, this new
Namask use case is uh UI, sorry, is
something that I'm not used to. So,
okay, now we're connected to Bipolia.
So,
so if I change my view here, it does not
affect to what to which one I'm
connected. Okay, cool. So, we can see
84532.
84532. Okay, we're good. Uh, I'm going
to deploy this. So, roll registry
contract. Where is the constructor? Um,
yeah constructor.
Yeah, just accepts to use this token on
basipoleia. So, if I go to book, this is
the address. So, I'm just going to
validate on basipoleia.
Sorry that this is the address that I'm
going to need to pass. Paste. Yeah, it's
USDC. Okay, cool. So, to deploy this,
I'm going to just paste the address here
and hit transact.
And hit transact. Okay, cool. Uh, let's
confirm this.
I have this transaction hash. So I'm not
going to monitor block scout. I'm just
going to use ether scan. So if I search
for this transaction hash, I can see
that I successfully created uh this
contract.
Uh cool. Now I am just going to wait for
all of you to do the same. So please uh
deploy the the new uh register rule
[clears throat] register contract to
baseolia or if you don't want to do that
just save this address. So I'm going to
save my address over here. So this is
the contract that's got created. And
here let's verification successful.
Okay.
A lot of stuff, a lot of new stuff here
uh in Remix as well since the last time
I checked it. So
here I have the address and uh here I
have the address. So here we go. So I'm
going to note write down this address.
You do the same as well. Then I will
need to get clone this repo
and um install install dependencies. I
already do that but essentially what you
need to do is get clone this repo.
Um
so git clone and then just npm install.
Um
here I already have that. So, in the
interest of time, I won't do that. But
what we need to do is once you get clone
it, you're just going to run npm
install.
Um, I'm going to wait for you to to do
that. Uh, and then we're going to
proceed with the with the next step. So,
just tell me once you uh get cloned uh
this repo.
Um but he tell me just write down in a
comment
uh comment section of YouTube stream. So
we have this last 20ish minutes to set
up all of this. So we have enough time.
So I'm going to wait for you to deploy
contract and then install it.
Once you
once you do that
and maybe we can cover that one as well,
you will need to create new env file in
a project route. So new env file, I'm
not going to show it to you but from
this example and just populate
all of the values from here. So here you
will need to paste your register
contract. In my case that will be this
address right?
Uh here you will paste your Gemini API
key, your private
wallet key,
uh your private key again. Uh and for
pushover notifications, just your
pushover ID and pushover API key. So
while we're waiting for uh for contracts
to be deployed for repos get clone and
installed and uh as a third step you can
populate your env file because if
anything's wrong with this environment
variables the demo might not work for
you. So take your time and set it up
properly. you should all already have
keys uh as a as a prerequisite for for
this workshop.
And I can see that Patrick already
deployed smart contract. So So nice job.
Congrats. Let's let's wait. That was
fast. Let's let's wait for the others uh
to to deploy it. Or if they don't want
to deploy, just use the the address. But
be aware that might be multiple alerts
to get clone the repo. MPM install and
then uh populate these environment
values like this. So I'm going to just
share this part of the screen that
explained all the values that needs to
be uh that needs to be uh shared.
What's the user key are for pushover? So
push over. If you go here, this is the
I'm going just going to toss this keys,
but this is the the user key that you
that you need to that you need to pass.
Okay.
And another one which is API key is I
think from here. Yeah. Uh no, sorry.
uh API.
I have it somewhere.
Oh yeah, here it is. And this is the API
key that you need to that you need to
pass. So these two so APIs for your
application. You'll need to create a new
one if you don't have it already. It
says like API token and this user key.
Uh don't reuse mine please.
Careful. Don't click on [clears throat]
anything sensitive. I want I'll just
gonna delete everything because like uh
I I won't use these keys in production.
But hopefully I I won't show you
disclose my private key. I mean it's
still like a a wallet that I use for for
this type of work only. It does not have
any real funds but still thank thanks
for the warning. Uh but yeah, I hope
that answers your question uh regarding
the push push over keys.
[sighs]
Um, and please do not use my keys
because my demo might fail because if
you if you all attach to uh to my keys
and I really really don't want to
receive all the alerts and push
notifications to my phone from all of
you. So just use uh use uh different
keys please that'll be that'll be
[snorts] that'll be fun thing to to see.
Um yeah anyway uh while we're waiting uh
for you to complete these steps once
again I'm going to I'm going to note
that uh you need to deploy the contract
did clone the repo and populate your env
file with these values
after that we are going to run the
server so after that you you will uh
configure your CRA workflow these uh
these values should already be there the
only one that you need to change is the
deployed rule register contract and uh
you you should be able to to run this
command to start the server. So that's
our next step. But first let's let's
wait for everyone to to complete uh this
part.
And I I like how I become a meme because
of sharing my my private keys. No, not
private keys, pushover keys uh on on on
screen. Don't worry, I'm going to I'm
going to just delete them after the
workshop. Uh anyways, uh once you once
you set all this up, just let me know in
the YouTube comment section and we can
move forward.
And do not forget to to hydrate.
[clears throat]
Okay, I hope that we we completed this
these steps. If you have issues,
[clears throat] just just let us know.
But uh let's
uh let's let's move move forward. So in
Siri alerts config.json.
So Siri alerts our workflow config
staging
uh JSON uh you should be you should uh
change this uh value to your rule
register contract
uh or this is the address of the one
that we
uh
that we we gave it to you but again uh
there might be new other rules from
other developers there. Uh the rest uh
is something that should be already
there but these are the full config uh
for this example. So chain selector name
needs to be Ethereum testio base one. Um
these are the feed addresses and gas
limit needs to be this. So the only
thing that you need to adjust here is
your rule registry
um contract address.
And I'm going to adjust mine. So,
I'm going to grab this contract
and paste it over here. That's it. So,
that should be the same as here. If I
cop copy this cursor, yeah, is the same
as here. So, I adjusted my my RO
registry address to the contract I
already uh to the contract I deployed
recently. Um,
okay. In the example, let's let's close
this thing.
Okay. as a next step. Once we do that,
again, just important, replace this with
with [clears throat] your address. If
you're unable,
just uh to deploy, just use this one.
And now the fun the fun begins. So now I
can run the dev server. So I'm going to
open my terminal
like this. I'm going to go type npm
rundev
server and hit enter.
And we can see that our server is live
at port 3000 that the payment for
request is 0.01 USDC. So on localhost 30
3000 we have two endpoints. So the one
is chat where we are going to use from
here uh for for natural language and
that one will uh hit the the alerts
endpoint which uh will trigger the X42
payment setable. So this is an
interactive chat. So we can just type
stuff here and this LLM powered server
should be able to um to decode what you
are trying to
um to to do. So what we are trying to do
now is to create an alert when BTC is
greater than 6,000. So with this
interactive chat UI, I can type create
an alert when
BTC is greater than 60,000. BTC is
greater than 601 23,000. And I can
really type uh here as a chat interface
and I can set I hit enter and what is
going on is I'm going to explain now
uh [sighs and gasps] we entered this uh
this natural text then it hit the po uh
the chat endpoint with HTTP post with
this message which is what I typed. So
using Gemini it started extracting alert
parameters and the result is BTC greater
than $60,000 which is uh which is
technically correct. So now our LLM
server is doing uh stuff for us. Then it
hit the alerts endpoint
before X42 payment. Then X42 handshake
happened. So we hit an initial request
then the the server returned the 402
payment required status code that we we
talked about it throughout the workshop.
Uh then we try then LM server said
client will process challenge and retry
with payment. Then another like another
step like hit the alerts endpoint. Uh
payment verified. We can see here that
alert was created. So if I go
and search for this transaction hash on
basipoleia
and hit enter.
Um it's not ready yet. Okay. I should be
able to see the setment there. Um
oh yeah, there it is. This is the ID.
Sorry. Uh sorry, this is not the
transaction hash. This is the ID. I
apologize. Here it is. This is the ID.
This is the input that we're going to
pass to the uh to the Siri workflow. And
here we can see that um payment
authorization happened. So for 0.01
USDC, this is my address. So 8FDA.
So
uh account one. Where can you see this?
Account details.
Oh my god. 8FA.
Uh I'm not a huge fan of this new
MetaMask UI. Uh and then [clears throat]
again the same alert with this ID was
created
and this is the transaction hash. So
instead of ID I should search for a
transaction hash. And here uh we can see
that we interacted with the USDC smart
contract on basoleia for 0.01.
So that's that's all all good.
Uh now we have this Siri workflow uh
payload that we need to copy for an HTTP
trigger. As a next step I'm going to uh
by the way if this interactive chat does
not work this option for you you can
always just do a standard curl and it
should work. So just make sure your
server is running.
uh then I will use that workflow payload
for HTTP trigger I saw uh by by copying
it uh and then we'll just going to now
simulate the alerts uh workflow. So to
do that I'm going to open another
terminal window. Uh I'm currently in the
root so I'm going to CD into Siri. I
need to run the this command Siri
workflow simulate alerts
and hit enter.
uh what we are going to do is that we're
going to simulate the HTTP trigger
because again we need to provide this
payload and this is the one step one one
step one time setup where we are uh
using the HTTP trigger to write a new
transaction on rule register contract to
have like a new registry so what I'm
going to do is select number two HTTP
trigger so number two hit enter the
similar thing that we did in a in
previous chapter where we like build
mental blocks we provided the dummy
input now I'm going to provide the
actual input so from here
so serial workflow payload copy for the
HTTP trigger I'm copying the whole input
and providing it here okay so it has
like the actual ID the actual asset
actual condition actual target price and
the actual dice step and I'm going to
hit enter
okay cool and we can see here that
a lot of stuff happened. The HTTP
trigger got triggered
uh that it tried to write to rule
registry contract available this
address. This is my my my contract I
deployed and the transaction was
successful. So if I try
searching for this transaction hash now
on basipoleia intercan
I should be able that 25 to see that 25
seconds ago I interacted
uh with uh with uh this contract and
that my report was submitted
successfully.
Okay. And in the book as well you will
see the similar uh example output.
Okay. So
the as as we said for the one time we're
going to use X42 sell payment. We're
going to use this server to trigger H to
trigger Siri with HTTP trigger and then
that HTTP trigger workflow will write a
new rule to our smart contract.
So we'll write a new rule to our smart
contract by calling the process report
write rule. Now there is this there are
these public Q functions to get all
rules. So what we are going to do as a
second step of this
exercise is to just use the crown trig
to hourly to monitor hourly for for ch
for the BTC in terms of USD prices from
the chain price and if it's the
condition is met to hopefully receive a
notification on our uh mobile phones. Uh
so again I'm going to run the same
command. So I'm going to clear this. So
again we need to simulate alerts
workflow but now we're going to select
chron trigger instead of http trigger
because now we're in the second part of
of the exercise. So we're going to do
chron trigger as we can see here in the
book. Select chron trigger and then
we're going to see what's what's going
on. So I'm going to hit number one
[sighs]
and we can see here that and my phone is
buzzing. I received notification.
[cough and clears throat] So this is
good. Uh
I just need to clear my my other
notifications. Uh but what happened here
is that uh serial workflow crown trigger
got triggered. It's fetched the prices
of BTCH and link in terms of USDC from
the chaining price feed. These are the
prices found one rules onchain because I
register one rule on chain. check that
and we got a success condition was met
because price of Bitcoin is greater than
$60,000. Then the pushover notification
got sent and now as you can see here now
I received my push notification. So this
is the the new one because you can see
it's I received it now and the price is
different from the one that I showed you
previously. So again, so the end goal
for you is to see this on your mobile
phones. The same push notification.
Um
just tell me if you if you see it. And
yeah, this is what what you should be
able to see. Just check your phone and
this is the notification that you should
be seeing. And I'm going to stop here
until you receive notifications on your
phone. As well
as an optional steps, we have uh two two
things to cover. We can view the balance
of the X42 receiver. The address that we
we uh uh that uh that's the address of
the rule registry contract because rule
registry has the get USDC balance
function. um
get USDC balance function. Oh,
something's wrong. Uh I know what it is.
I use the different contract. Never
mind. And also as an optional steps, I
can withdraw funds from this contract.
Uh so again, whatever is set in the NVA
file. In my NV file, the address of the
contract I deployed previously was set.
So I'm not going to open my ENV file, of
course. Uh but uh I can I can check that
and uh and withdraw funds if needed. But
before all that, we just need to see the
the price uh alert notifications on your
phone. So if you see the notification,
just uh let us know in a chat. So again,
you should be able to see something like
this.
And
this pretty much concludes our workshop.
If you're not seeing notifications or
you're having some kind of issues down
here there is a troubleshoot guide. So
if there's no notification, make sure
you have these two values in ENV file.
Um sometimes you will see rate limit
exceeded error when you run uh when you
run um Gemini LM software uh server that
means that you need to basically even
though it's a free tire you need to add
billing. So you just go to uh that's 4
429 status code. So just go to your
Gemini API key dashboard and just enable
uh it won't it won't cost you any money
but you need to enable billing. So
that's that's something that can go
wrong. And just make sure that uh all of
these values are corrected. So you have
contract address in ENV and staging. You
have enough E and USDC on base. Uh
you're logged in. Um and yeah, your
private key have as I said enough USDC
on base. So
hopefully if everything go well you will
see the the push notification
like this.
Here we go.
Uh while we're waiting for your uh push
notifications to arrive
um we will we will have we will conclude
this uh session with a with this
workshop with a Q&A session. So now is
the time to also think about any
questions you might have that you want
to ask. Um either myself or someone from
the chat will will answer. Um
because [clears throat]
uh this this event is all about you. So
if there's anything unclear regarding C,
regarding X42, regarding the demo,
something does not work, uh please let
us know. Um uh and uh just while we're
waiting for uh for notifications to
arrive uh for a couple more minutes,
then we're going to start with the Q&A
session. So again, the the goal is to
see the the notification on your phone.
I hope this was this was fun and I hope
this was the useful um usage of your
time. uh we really try to go above and
beyond with this this workshop to really
uh teach you some advanced patterns
something something really useful. Again
the whole source code is available at
this uh this repo so you can deep dive
into the code. There is again in the
readmi file pretty much the same uh se
steps and instructions to rerun
uh the the whole the whole end to end
flow on your at your own time at your
own with your own pace
again and um code that's heavily
documented so you can easily read it and
understand what's what's going on.
Um, very informative. Can't believe 2
hours has almost went by. Okay. Yeah.
Uh, me too. It was like I was constantly
looking at the at the clock to make sure
we're on time, but I have a feeling like
it was like 15 minutes long. Uh, okay.
While we're waiting for these
notifications to arrive, as I said, our
next step will be a Q&A session. So this
is your time to ask anything about Siri
workflows capabilities, anything about
X42 and integration patterns, how we can
build with these technologies, best
practice tips, etc. Uh important URLs
are are here again. So this book
repository and documentation for the two
technologies and finally we have a
feedback survey. So if you don't mind,
we really appreciate if you if you
complete this survey. uh it's going to
take you it's going to take like two
minutes max. Uh but it's something that
uh we we value a lot because we're
always looking constantly for your
feedback and one piece of feedback from
the CCP master classes we got is that
you you wanted more advanced uh more
advanced use cases. So that's why we
came with with something like this. So
anything that you like did not like
about this specific masterass. So now
we're just talking about the master
class and the uh and the execution and
the flow with the fireside chat at the
beginning uh which is a new thing that
we that we added etc. uh please know
that in the survey uh so so we can uh we
can improve uh for the next master
classes. And um now is your time as I
said to write questions
uh in the chat
um that we we have not answered. Uh I I
was monitoring the chat and I saw that
Zubin and Noland asked a lot of answered
a lot of questions already. But any
final uh final questions that you might
have please please writing uh writing
down uh here's the first one. So are
there any plans to integrate ZKPs or
ZKVMs to provide cryptographic
guarantees and not rely so only on
business default torance consensus? Uh
because what if one more than one or
third nodes act maliciously? That's a
good question. However, I don't think
Zik will will solve the the problem
completely because with Zikps, I can
prove that I have an info of something
that's publicly
known without uh revealing u my inputs
or whatever. So, it's it's not something
like that can be easily replic
replicable for the consensus use case.
But that's a good question. Um what
else? automation and functions will go
to migrate completely to CR or it will
going to continue working for people
that only needs them. I don't have exact
uh timelines or that info uh at the
moment but what I will suggest to you is
that if you're planning to use
automation or functions for for a new
project definitely consider C because
it's more featurerich uh it's
featurerich sorry uh it's uh it's more u
more powerful in general uh so that's
definitely something that I will uh
suggest to you for all projects that use
functions or automation
uh and they're like in production then
we we're already probably in talk with
you. So I don't expect any any major
changes there there yet. Uh but we'll be
in touch for sure. Um
let's see. Let's see. Um
now
like they will exist like for a while
but I don't have like the actual
timelines. That's that's pretty much uh
what I wanted to say. Um how are you
guys looking at serial workflow
computation costs? We're building some
good stuff. Uh and will be some kind of
per second fee. Uh that's a good
question. Um basically CV like for
deployment to production is still like
an early access. Uh so when when you are
when you submit to early access and
apply uh someone will reach out so you
can uh you can um narrow all these tiny
details which are definitely important
like like computation costs for sure. Um
okay I don't know what OITC is so I
don't think I can answer that one
unfortunately.
Um, a hackathon is up on its way, right?
Or a twoe boot camp would be awesome.
So, yeah, I mentioned that uh in so this
was like a two hours long event in
January. U please closely monitor our
social media channels and newsletter. Uh
we will launch a two-day Siri boot camp.
to much with much more content than this
one because this was two hours that were
going to be two day and based on the
survey we might or might not add
homework because we did had homework for
tokeniz tokenized RW assets. So that's
also important piece of feedback we're
looking for and then following the
two-day boot camp we will have a series
specific hackathon in February. So make
sure you team up with somebody, come up
with cool ideas to to build with Siri
and more details for that hackathon will
be uh shared soon as well. Uh so just
closely monitor our socials and make and
be prepared that in January and February
be all about uh C starting with with the
boot camp and then with the actual
hackathon.
Um
can we have a link to the feedback form?
Yes. Uh how does this connect with the
wis and training infrastructure or does
it yet? So chaining infrastructure
basically as I said all of these
workflows and capabilities have their
own workflow and capability dons. Dons
stands for decentralized oracle network.
So this is the same piece of technology
in the same chain link node client that
we are using for years now for price
feeds CCIP automation functions etc. So
um so the same same secure
infrastructure that powers other chain
linking products uh also is powering CR
but CR is kind of like a base layer as
as a car said at the beginning uh this
is something that we used internally
before deciding to to open to the public
because uh um you you know that when I
created a new project with Siri in it
there was like a custom workflow with
proof reserve feeds so it's definitely
possible
uh to have like completely uh fully
functional production ready feeds using
Siri as a base layer and that's
something that we actually did for some
of the nonvm chain chain families
recently. We use C under the hood for
for price feed. So that's how it
connects to chaining infrastructure
basically is the same security and same
nodes uh node technology that you're uh
used to already.
Um feedback form. Yes. Hackathon. Great.
Uh okay. Uh cool. If there are no any uh
more questions. Uh okay. I just want to
show you something more. So this is your
holiday gift from me to you in the bonus
section. I know that we use AI nowadays
for a lot of coding uh prompting etc. So
I know that during boot camp and even
today we learn a little bit about series
syntax and learning about series syntax
is important because it's easier to
debug um easier to write workflows etc.
But given that we're living in an EA uh
era uh we created this do two bonus uh
prompting guides as your as I said
holidays gift to you. So for both
Typescript and and Go. So basically you
just need to provide this huge markdown
file as a context to your uh to your
editor agent or whatever uh you're going
to use. So cloud code cursor codeex
anything works. So just your AI agent
coding agent needs to have this in a
this uh as a context somewhere. Uh and
then at the very end you can provide
user prompt here. So this is just a
placeholder. Uh just change what you
want to ask and um uh and uh uh
hopefully all of these coding agents
will be able to to generate uh bug-free
um or at least compilation without
compilation issues workflows in either
Typescript and in Go as well. So
prompting in Go it's use the same same
uh format. You have all these system
contexts that a agent needs to be aware
of and then you provide your uh your
prompt error specific request over here.
Um
uh what uh are there the same project on
go? Actually kind of they all do the
same thing. However, the Go code is a
bit different syntax wise. It's just
syntactic sugar and also with Go you can
use Go standard library for example in
your workflow while with TypeScript
there's like npm packages that you can
import. So technically like there is a
functionality available in a go standard
library u that's not available in
typescript but I doubt there is some
some of them then that that can be a
different because you can use that one
but but essentially like the mental
model is the same for for both languages
and our plan is to follow with more
languages hopefully in the future. So in
the survey form as well if you want to
note down somewhere your favorite
language or what or now in a YouTube
comments which language you would like
to see next uh then we can also take
that as a as a piece of feedback um
after this workshop.
[sighs and snorts]
Um yeah can you elaborate on how this
connect series is a runtime environment
and you can interact with offchain and
onchain systems with ease. Um I think
that pretty much sums it up. So with CR
we it's like a platform thing. There is
a CLI to compile and simulate workflows.
Workflows are a piece of offchain code
written in T3 or go that connects uh
real world uh with smart contracts on
any blockchain. So you can uh write read
from different contracts from different
chains all in as part of one one
workflow and u there's like bunch of
capabilities like triggers interaction
with API endpoints etc that are kind of
like a building blocks for these
workflows and we are right on time uh
thank you so much for for joining this
this workshop I really appreciate you
staying with me for the full two hours
again of the speaking of hands-on
exercise, the goal is to see push
notification like this on your phone. So
hopefully if you haven't seen it during
the the master class, you can uh just
repeat the process on your own page
afterwards and you can uh you can always
tag me on Twitter with pictures and
stuff once you see the notifications
like with screenshots if you want, of
course. Uh thank you so much and I hope
I will see you soon. uh hopefully in
January for the boot camp. And um happy
holidays everyone. Have a have a nice
one. Thank you.
Join us on December 16 for a masterclass with Base and Chainlink Labs: an in-depth, developer-focused walkthrough of how to use the Chainlink Runtime Environment and x402 agentic payments.