Skip to content

Commit

Permalink
Dev tooling (#42)
Browse files Browse the repository at this point in the history
* Edits all additions, updates what to build page

* Add dev tooling page back to sidebar

* fixes broken links error

* fix typo

* save how-to index page properly

* Add back simple contract to make sidebar carets same size
  • Loading branch information
andytudhope authored Nov 7, 2023
1 parent d786cb9 commit 1d188a8
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ jobs:
-e "https://github.com/flashbots/suave-bridge" \
-e "https://github.com/flashbots/suave-specs" \
-e "https://github.com/flashbots/suapp-examples" \
-e "https://github.com/flashbots/suave-viem"
-e "https://github.com/flashbots/suave-viem" \
-e "https://suave.flashbots.net"
2 changes: 1 addition & 1 deletion docs/builder-solidity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ This ensures confidentiality **and** improves efficiency, enabling computation t

We recommend [this early research talk from Andrew Miller](https://youtu.be/DhsDFKnHPa0?t=344) to get a sense of the ideas from which builder solidity has grown.

Please note that the pseudo code Andrew shows is now outdated and you are better off learning from our [how to create contracts guide](/how-to/create-contracts/deploy-custom) above, or looking directly at our [list of available precompiles](/technical/specs/rigil/precompiles). That said, the framework used in this talk and the background provided should still prove useful when writing your own builder solidity contracts.
Please note that the pseudo code Andrew shows is now outdated and you are better off learning from our [how to create contracts guide](/how-to/create-contracts/) above, or looking directly at our [list of available precompiles](/technical/specs/rigil/precompiles). That said, the framework used in this talk and the background provided should still prove useful when writing your own builder solidity contracts.
14 changes: 14 additions & 0 deletions docs/dev-tooling.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Dev Tooling
description: An up-to-date list of software to help you build on SUAVE
---

Here is an up-to-date list of software and repositories to help you build on [SUAVE Rigil](/technical/specs/rigil):

- [Golang SDK](/how-to/interact-with-suave/golang-sdk)
- [Typescript SDK: SUAVE-viem](/how-to/interact-with-suave/typescript-sdk)
- [Example Golang Script](/how-to/interact-with-suave/deploy-and-test-example-suapp)
- [SUAVE Rigil Specs](/technical/specs/rigil)
- [SUAPP Examples Repo](https://github.com/flashbots/suapp-examples)
- [suave-geth repo](https://github.com/flashbots/suave-geth)
- [SAUVE Forge](https://github.com/flashbots/suave-geth/blob/main/suave/sol/libraries/SuaveForge.sol)
2 changes: 1 addition & 1 deletion docs/how-to/create-contracts/confidential.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords:

# Confidential contracts on SUAVE

We can extend [the contract we deployed in the previous guide](/how-to/create-contracts/deploy-custom) so that it emits the results of the simulation performed by the MEVM allowed to decrypt the confidential inputs.
We can extend [the contract we deployed in the previous guide](/how-to/create-contracts/) so that it emits the results of the simulation performed by the MEVM allowed to decrypt the confidential inputs.

```solidity
pragma solidity ^0.8.8;
Expand Down
6 changes: 2 additions & 4 deletions docs/how-to/create-contracts/deploy-custom.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ keywords:

# Deploy a custom contract

This sub-section of guides will walk you through creating and deploying increasingly complex smart contracts.
Now, let's write our own simple contract that illustrates how to use confidential inputs. We'll also focus on **how to to deploy custom contracts**.

We'll begin with a simple contract that illustrates how to use confidential inputs.

This focus of this first guide **how to to deploy custom contracts**. The following guides will provide more details about precompiles, the programming model, and the data flows we expect to see in SUAVE.
The following guides will provide more details about precompiles, the programming model, and the data flows we expect to see in SUAVE.

## 1. Write the contract

Expand Down
93 changes: 93 additions & 0 deletions docs/how-to/create-contracts/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
title: Create Contracts
description: Deploy a precompiled exxample contract on SUAVE
---

This sub-section of guides will walk you through creating and deploying increasingly complex smart contracts.

We've written a number of example smart contracts to help get you started thinking about what's possible.

This script uses the [golang SDK](/how-to/interact-with-suave/golang-sdk), and deploys an example contract we've already set up to keep things maximally simple.

Inside `suave-geth` repo, create a new file in `suave/devenv/cmd` called `deploy.go`:

```go
package main

import (
"crypto/ecdsa"
"fmt"

_ "embed"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/suave/e2e"
"github.com/ethereum/go-ethereum/suave/sdk"
)

var (
// This is the address we used when starting the MEVM
exNodeEthAddr = common.HexToAddress("b5feafbdd752ad52afb7e1bd2e40432a485bbb7f")
exNodeNetAddr = "http://localhost:8545"
// This account is funded in your local SUAVE network
// address: 0xBE69d72ca5f88aCba033a063dF5DBe43a4148De0
fundedAccount = newPrivKeyFromHex(
"91ab9a7e53c220e6210460b65a7a3bb2ca181412a8a7b43ff336b3df1737ce12"
)
)

var (
mevShareArtifact = e2e.MevShareBidContract
)

func main() {
rpcClient, _ := rpc.Dial(exNodeNetAddr)
mevmClt := sdk.NewClient(rpcClient, fundedAccount.priv, exNodeEthAddr)

var mevShareContract *sdk.Contract
_ = mevShareContract

txnResult, err := sdk.DeployContract(mevShareArtifact.Code, mevmClt)
if err != nil {
fmt.Errorf("Failed to deploy contract: %v", err)
}
receipt, err := txnResult.Wait()
if err != nil {
fmt.Errorf("Failed to wait for transaction result: %v", err)
}
if receipt.Status == 0 {
fmt.Errorf("Failed to deploy contract: %v", err)
}

fmt.Printf("- Example contract deployed: %s\n", receipt.ContractAddress)
mevShareContract = sdk.GetContract(receipt.ContractAddress, mevShareArtifact.Abi, mevmClt)
}

// Helpers, not unique to SUAVE

type privKey struct {
priv *ecdsa.PrivateKey
}

func newPrivKeyFromHex(hex string) *privKey {
key, err := crypto.HexToECDSA(hex)
if err != nil {
panic(fmt.Sprintf("failed to parse private key: %v", err))
}
return &privKey{priv: key}
}
```

If you now run:

```bash
go run suave/devenv/cmd/deploy.go
```

You should see the address of your new example contract printed in the terminal.

The important parts to note when deploying contracts are the call to [`e2e`](https://github.com/flashbots/suave-geth/blob/main/suave/e2e/contracts.go), which helps generate ABIs and bytecode for contracts, and the `sdk.DeplyContract` and `sdk.GetContract`.

If you're able to generate the necessary ABIs and bytecode, you should be able to deploy any contract you like using the above pattern.
14 changes: 1 addition & 13 deletions docs/how-to/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,4 @@ SUAVE is focused on delivering credible, confidential computation that enables y
2. **Compute confidentially**.
- Builder solidity lets you request confidential computation, where your transaction data is encrypted to specific actors. Public contracts with verifiable logic, combined with confidential data, means that SUAVE can be seen as an open marketplace for mechanisms we can all inspect, collaborate on, and compete with to produce the most efficient MEV applications, while nevertheless protecting everyone's privacy.

> **SUAVE enables anyone to build and deploy MEV applications, on a decentralized network, which were not possible until today.**
## Development Stack

Here is an up-to-date list of software and repositories to help you build on [SUAVE Rigil](/technical/specs/rigil):

- [Golang SDK](/how-to/interact-with-suave/golang-sdk)
- [Typescript SDK: SUAVE-viem](/how-to/interact-with-suave/typescript-sdk)
- [Example Golang Script](/how-to/interact-with-suave/deploy-and-test-example-suapp)
- [SUAVE Rigil Specs](/technical/specs/rigil)
- [SUAPP Examples Repo](https://github.com/flashbots/suapp-examples)
- [suave-geth repo](https://github.com/flashbots/suave-geth)
- [SAUVE Forge](https://github.com/flashbots/suave-geth/blob/main/suave/sol/libraries/SuaveForge.sol)
> **SUAVE enables anyone to build and deploy MEV applications, on a decentralized network, which were not possible until today.**
2 changes: 1 addition & 1 deletion docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Welcome. Let's start building better mechanisms.
Once you have SUAVE running, there are two broad categories of work you can get involved with:

<div class="introGrid">
<a href="/how-to/create-contracts/deploy-custom" class="introLink">
<a href="/how-to/create-contracts/" class="introLink">
<div class="introBlock">
<div class="introImage">
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"><path d="M10.1916 8.65L10.7233 11.8383C11.0658 13.8947 12.0425 15.7926 13.5166 17.2667L16.25 20L15.605 21.2917C15.2433 22.0133 15.385 22.885 15.955 23.455L18.2016 25.7017C18.5516 26.0517 18.75 26.53 18.75 27.0267V28.8417C18.75 29.5517 19.15 30.2 19.7866 30.5183L20.0416 30.645C20.7633 31.0067 21.635 30.865 22.205 30.295L23.41 29.09C25.2681 27.2315 26.5862 24.903 27.2233 22.3533C27.3062 22.0228 27.2942 21.6756 27.1886 21.3516C27.0831 21.0276 26.8883 20.74 26.6266 20.5217L24.41 18.675C23.9916 18.325 23.44 18.1767 22.9016 18.2667L20.9516 18.5917C20.6574 18.6407 20.3557 18.6187 20.0716 18.5277C19.7876 18.4367 19.5293 18.2792 19.3183 18.0683L18.8266 17.5767C18.6525 17.4026 18.5144 17.1959 18.4202 16.9684C18.326 16.7409 18.2775 16.4971 18.2775 16.2508C18.2775 16.0046 18.326 15.7608 18.4202 15.5333C18.5144 15.3058 18.6525 15.0991 18.8266 14.925L19.0433 14.705C19.3219 14.4264 19.6812 14.2427 20.0701 14.1799C20.459 14.117 20.8578 14.1783 21.21 14.355L22.215 14.8583C22.4682 14.9855 22.7551 15.0296 23.0349 14.9845C23.3146 14.9393 23.5731 14.8072 23.7734 14.6068C23.9738 14.4064 24.106 14.148 24.1511 13.8682C24.1963 13.5885 24.1521 13.3016 24.025 13.0483L23.75 12.5L25.8433 11.105C26.9289 10.3807 27.8067 9.38573 28.39 8.21834L28.6333 7.73167M10.1916 8.65C7.8285 10.6922 6.16176 13.421 5.42394 16.4559C4.68613 19.4908 4.91405 22.6803 6.07591 25.5794C7.23777 28.4785 9.27561 30.9426 11.9051 32.628C14.5346 34.3134 17.6247 35.1359 20.7441 34.9809C23.8635 34.8258 26.8567 33.7009 29.3061 31.7631C31.7555 29.8252 33.539 27.1712 34.4076 24.1711C35.2762 21.1711 35.1867 17.9747 34.1516 15.028C33.1165 12.0812 31.1873 9.52941 28.6333 7.73167M10.1916 8.65C12.9142 6.29069 16.3974 4.99445 20 5C23.215 5 26.1933 6.01 28.6333 7.73167" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>
Expand Down
2 changes: 2 additions & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
items: [
'what-is-suave',
'novel-use-cases',
'dev-tooling',
'technical/specs/rigil/glossary'
],
},
Expand Down Expand Up @@ -40,6 +41,7 @@ module.exports = {
{
type: 'category',
label: 'Create Contracts',
link: { type: 'doc', id: 'how-to/create-contracts/index' },
items: [
'how-to/create-contracts/deploy-custom',
'how-to/create-contracts/confidential',
Expand Down

0 comments on commit 1d188a8

Please sign in to comment.