Skip to content

Commit

Permalink
update suave-viem code examples (#104)
Browse files Browse the repository at this point in the history
* update suave-viem code examples

* fix invalid code block language
  • Loading branch information
zeroXbrock authored Mar 20, 2024
1 parent 1a98c78 commit 21925e4
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions docs/tools/typescript-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,26 @@ Sending Confidential Compute Requests works slightly differently, but most other

:::

This page describes how to work with the SUAVE-viem TypeScript SDK. The SDK simplifies interaction with the SUAVE Chain and provides easy-to-use functions to send transactions and query data. Below, you'll find steps on how to instantiate the library, symlink, and perform some basic actions.
This page describes how to work with the SUAVE-viem TypeScript SDK. The SDK simplifies interaction with the SUAVE Chain and provides easy-to-use functions to send transactions and query data. Below, you'll find steps on how to install the library and perform some basic actions.

## Installation

The [`@flashbots/suave-viem`](https://www.npmjs.com/package/@flashbots/suave-viem) package is available on NPM, and can be installed with any NPM-based package manager, such as **npm**, **yarn**, or **bun**.

:::warning

Alpha Release Version

Note: you must use the following reference when importing, or else your project won't import the required types. This is a temporary measure while we fix the tests that are failing in CI, which prevents a full release.

`@flashbots/suave-viem@main`

:::

<Tabs>
<TabItem value="npm" label="npm">
```bash
npm i @flashbots/suave-viem@main
npm i @flashbots/suave-viem
```
</TabItem>
<TabItem value="yarn" label="yarn">
```bash
yarn add @flashbots/suave-viem@main
yarn add @flashbots/suave-viem
```
</TabItem>
<TabItem value="bun" label="bun">
```bash
bun add @flashbots/suave-viem@main
bun add @flashbots/suave-viem
```
</TabItem>
</Tabs>
Expand Down Expand Up @@ -129,7 +119,6 @@ First, instantiate a new wallet of your own, and fetch the current gas price fro

```typescript
const PRIVATE_KEY: Hex = '<your_priv_key>';
const gasPrice = await publicClients.suaveLocal.getGasPrice();

const wallet = getSuaveWallet({
transport: http(SUAVE_RPC_URL),
Expand All @@ -148,8 +137,7 @@ import {TransactionRequestSuave} from '@flashbots/suave-viem/chains/suave/types'
const fundTx: TransactionRequestSuave = {
type: '0x0',
value: 100000000000000001n,
gasPrice: gasPrice + 1000000000n,
chainId: suaveRigil.id,
gasPrice: 10000000000n, // 10 gwei is typically fine for testing
to: wallet.account.address,
gas: 21000n,
};
Expand Down Expand Up @@ -181,7 +169,7 @@ while (true) {

If you once again run `bun run index.ts`, you should see something like the following logged to your terminal:

```bash
```txt
sent fund tx 0xe6f7385c6992c91941fe10e43feaf987cb4377f302915945b747fcb0e0a7f40a
formatting tx receipt
fund tx landed {
Expand Down

0 comments on commit 21925e4

Please sign in to comment.