Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small necessaries #133

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module.exports = {
type: 'link',
label: 'Forum',
href: 'https://collective.flashbots.net/c/suave/27',
},{
type: 'link',
label: 'Telegram',
href: 'https://t.me/+MxHZuQDJR_4yYTAx',
},
],
},
Expand Down
12 changes: 8 additions & 4 deletions docs/tutorials/onchain-offchain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,17 @@ INFO [03-26|10:30:27.900] Waiting for the transaction to be mined...
INFO [03-26|10:30:28.004] Transaction mined status=1 blockNum=8
```

What's going on here? Well, we can't emit the results of offchain computation directly onchain, because that leaks whatever happened in the computation, which is precisely what we want to avoid doing.
What's going on here?

## Using SUAVE-STD
:::info

If we want the relevant part of the results of our offchain computation to result in things happening onchain, we need to be a little more clever with how we write our contracts.
Any function intended to be run offchain cannot emit events or trigger state changes. Instead, place a callback to an onchain function at the end of whatever offchain logic you want to run, and trigger any state changes from the onchain function.

In order to make this easy, we maintain a [useful library called `SUAVE-STD`](https://github.com/flashbots/suave-std) which enables you to do anything from emitting logs (like we're trying to do in this tutorial), to making arbitrary http calls, using Chat GPT in your contracts, encoding and decoding JSON, RLP encoding/decoding transactions, and doing various other commonly useful things.
:::

## Using SUAVE-STD

In order to make working with offchain logic and onchain callbacks easier, we maintain a [useful library called `SUAVE-STD`](https://github.com/flashbots/suave-std) which enables you to do anything from emitting logs (like we're trying to do in this tutorial), to making arbitrary http calls, using Chat GPT in your contracts, encoding and decoding JSON, RLP encoding/decoding transactions, and doing various other commonly useful things.

First, you'll need to add and commit the changes you've made already before we can install `SUAVE-STD`:

Expand Down
Loading