Skip to content

Commit 10ed886

Browse files
authored
Merge pull request #1559 from onflow/cross_vm_app_docs_cws
Croos VM App Doc Edits.
2 parents 9ee7298 + 6ad60bf commit 10ed886

File tree

7 files changed

+355
-598
lines changed

7 files changed

+355
-598
lines changed

docs/blockchain-development-tutorials/cross-vm-apps/add-to-wagmi.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ keywords:
2121
- supercharge your EVM app with Cadence
2222
---
2323

24-
# Add Flow Cadence to Your wagmi App
24+
# Add Flow Cadence to your wagmi app
2525

26-
This tutorial demonstrates how to enhance your existing wagmi/RainbowKit application with Flow Cadence capabilities. By integrating the Flow Client Library (FCL) with your EVM stack, you can unlock powerful features like batch transactions with a single signature.
26+
This tutorial demonstrates how to enhance your existing wagmi/RainbowKit application with Flow Cadence capabilities. When you integrate the Flow Client Library (FCL) with your EVM stack, you can unlock powerful features like batch transactions with a single signature.
2727

28-
## Video Overview
28+
## Video overview
2929

3030
<div style={{ position: 'relative', paddingBottom: '56.25%', height: 0, overflow: 'hidden', maxWidth: '100%' }}>
3131
<iframe
@@ -40,49 +40,49 @@ This tutorial demonstrates how to enhance your existing wagmi/RainbowKit applica
4040
4141
## Objectives
4242

43-
After completing this guide, you'll be able to:
43+
After you complete this guide, you'll be able to:
4444

45-
- Add FCL to your existing wagmi/RainbowKit application
46-
- Configure FCL to work alongside your EVM wallet connections
47-
- Implement batch transactions that execute multiple EVM calls in a single Cadence transaction
48-
- Display both Cadence and EVM addresses in your application
45+
- Add FCL to your existing wagmi/RainbowKit application.
46+
- Configure FCL to work alongside your EVM wallet connections.
47+
- Implement batch transactions that execute multiple EVM calls in a single Cadence transaction.
48+
- Display both Cadence and EVM addresses in your application.
4949

5050
## Prerequisites
5151

52-
### Next.js and Modern Frontend Development
52+
### Next.js and modern frontend development
5353

54-
This tutorial uses [Next.js]. You don't need to be an expert, but it's helpful to be comfortable with development using a current React framework. You'll be on your own to select and use a package manager, manage Node versions, and other frontend environment tasks. If you don't have your own preference, you can just follow along with us and use [npm].
54+
This tutorial uses [Next.js]. You don't need to be an expert, but it's helpful to be comfortable with development with a current React framework. You'll be on your own to select and use a package manager, manage Node versions, and other frontend environment tasks. If you don't have your own preference, you can just follow along with us and use [npm].
5555

56-
### Solidity and Cadence Smart Contract Development
56+
### Solidity and Cadence smart contract development
5757

58-
Apps using the hybrid approach can interact with both [Cadence] and [Solidity] smart contracts. You don't need to be an expert in either of these, but it's helpful to be familiar with how smart contracts work in at least one of these languages.
58+
Apps that use the hybrid approach can interact with both [Cadence] and [Solidity] smart contracts. You don't need to be an expert in either of these, but it's helpful to be familiar with how smart contracts work in at least one of these languages.
5959

60-
### Onchain App Frontends
60+
### Onchain app frontends
6161

62-
We're assuming you're familiar with [wagmi], [viem], and [RainbowKit]. If you're coming from the Cadence, you might want to take a quick look at the getting started guides for these platforms. They're all excellent and will rapidly get you up to speed on how the EVM world commonly connects their apps to their contracts.
62+
We assume that you're familiar with [wagmi], [viem], and [RainbowKit]. If you come from the Cadence, you might want to take a quick look at the getting started guides for these platforms. They're all excellent and will rapidly get you up to speed on how the EVM world commonly connects their apps to their contracts.
6363

64-
## Create an App
64+
## Create an app
6565

66-
Start by creating an app using [RainbowKit]'s scaffold:
66+
To start, create an app with [RainbowKit]'s scaffold:
6767

6868
```bash
6969
npm init @rainbow-me/rainbowkit@latest
7070
```
7171

7272
## Install Required Dependencies
7373

74-
Continue by adding the necessary Flow dependencies to your project:
74+
Next, add the necessary Flow dependencies to your project:
7575

7676
```bash
7777
npm install @onflow/fcl @onflow/fcl-rainbowkit-adapter
7878
```
7979

8080
These packages provide:
8181

82-
- `@onflow/fcl`: The Flow Client Library for interacting with the Cadence VM
83-
- `@onflow/fcl-rainbowkit-adapter`: An adapter that allows RainbowKit to work with FCL-compatible wallets
82+
- `@onflow/fcl`: The Flow Client Library for interacting with the Cadence VM.
83+
- `@onflow/fcl-rainbowkit-adapter`: An adapter that allows RainbowKit to work with FCL-compatible wallets.
8484

85-
## Step 2: Configure FCL in Your wagmi Setup
85+
## Step 2: Configure FCL in your wagmi setup
8686

8787
Update your wagmi configuration (`src/wagmi.ts`) to include FCL:
8888

@@ -127,10 +127,10 @@ export const config = createConfig({
127127
});
128128
```
129129

130-
## Step 3: Add the Batch Transaction Utility
130+
## Step 3: Add the batch transaction utility
131131

132132
<Callout type="info">
133-
You can skip this step by using a [pre-built utility from the `@onflow/react-sdk`] package. However, if you want to understand how batch transactions work under the hood, continue with this custom implementation.
133+
You can skip this step if you use a [pre-built utility from the `@onflow/react-sdk`] package. However, if you want to understand how batch transactions work under the hood, continue with this custom implementation.
134134
</Callout>
135135

136136
Create a custom hook in `src/hooks/useBatchTransactions.ts` to handle batch transactions. This utility allows you to execute multiple EVM transactions in a single Cadence transaction:
@@ -359,7 +359,7 @@ export function useBatchTransaction() {
359359

360360
## Step 4: Implement the UI
361361

362-
Now, update your application's `page.tsx` to use the batch transaction utility. Update
362+
Now, update your application's `page.tsx` to use the batch transaction utility. Update:
363363

364364
```tsx
365365
'use client';
@@ -451,43 +451,43 @@ function Page() {
451451
export default Page;
452452
```
453453

454-
## Step 5: Test Your Application
454+
## Step 5: Test Your application
455455

456456
1. Start your development server:
457457

458458
```bash
459459
npm run dev
460460
```
461461

462-
2. Connect your wallet using the RainbowKit `ConnectButton`
462+
2. Connect your wallet with the RainbowKit `ConnectButton`
463463

464464
- Make sure to use a Cadence-compatible wallet like Flow Wallet
465465

466-
3. Click the "Send Batch Transaction" button
466+
3. Click "Send Batch Transaction"
467467

468-
- You'll be prompted to approve the Cadence transaction
469-
- This transaction will execute multiple EVM calls in a single atomic operation
468+
- You'll be prompted to approve the Cadence transaction.
469+
- This transaction will execute multiple EVM calls in a single atomic operation.
470470

471471
4. Observe the results
472-
- The Cadence transaction ID will be displayed
473-
- The results of each EVM transaction will be shown
472+
- The Cadence transaction ID will be displayed.
473+
- The results of each EVM transaction will be shown.
474474

475475
## How It Works
476476

477477
When you call `sendBatchTransaction`, the following happens:
478478

479-
1. A Cadence transaction is created that includes all your EVM calls
480-
2. The transaction is executed using FCL's `mutate` function
481-
3. The Cadence transaction calls each EVM transaction in sequence
482-
4. If any transaction fails and `mustPass` is true, the entire batch is rolled back
483-
5. The results of each EVM transaction are returned
479+
1. A Cadence transaction is created that includes all your EVM calls.
480+
2. The transaction is executed with FCL's `mutate` function.
481+
3. The Cadence transaction calls each EVM transaction in sequence.
482+
4. If any transaction fails and `mustPass` is true, the entire batch is rolled back.
483+
5. The results of each EVM transaction are returned.
484484

485485
This approach gives you several advantages:
486486

487-
- **Atomic Operations**: All transactions succeed or fail together
488-
- **Single Signature**: Users only need to sign one transaction
489-
- **Gas Efficiency**: Reduced gas costs compared to separate transactions
490-
- **Simplified UX**: Users don't need to approve multiple transactions
487+
- **Atomic Operations**: All transactions succeed or fail together.
488+
- **Single Signature**: Users only need to sign one transaction.
489+
- **Gas Efficiency**: Reduced gas costs compared to separate transactions.
490+
- **Simplified UX**: Users don't need to approve multiple transactions.
491491

492492
## Conclusion
493493

0 commit comments

Comments
 (0)