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

Staging #114

Merged
merged 7 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Tutorial: Build an NFT App powered by FuseBox.
  • Loading branch information
emmaodia committed Feb 14, 2024
commit d6ef25e6a9c17a00e705bda78edb01f98190f7c2
26 changes: 26 additions & 0 deletions docs/basics/account-abstraction/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Account Abstraction
sidebar_position: 5
---

## The Power of Account Abstraction and the ERC-4337 Standard

Welcome to Fuse's comprehensive guide on Account Abstraction and the ERC-4337 standard. This series explores how Account Abstraction is revolutionizing Smart Contract Wallets' user experience, bolstering the potential for a Web3 revolution.

## History and Evolution of Account Abstraction

Ethereum's inception introduced an account-based model, comprising Externally Owned Accounts (EOAs) and Contract Accounts, a structure extending to all EVM-compatible chains, including Fuse. EOAs, pivotal for transactions on Fuse, come with their drawbacks, notably the reliance on a cryptographic key pair and the cumbersome process involving gas fees for transaction execution. This complexity poses a significant barrier to new users and risks fund loss if private keys are misplaced, fragmenting the Web3 onboarding experience.

Ethereum's response was Account Abstraction, aiming to streamline and secure Web3 interactions by simplifying user processes.

## Account Abstraction: A Transformational User Experience

Debuted by Ethereum's co-founder Vitalik Buterin, Account Abstraction aims to make the Web3 experience more user-friendly by hiding the intricacies of transactions. This initiative, highlighted at WalletCon in Denver (March 2023) and EthCC in Paris (July 2023), seeks to refine wallet functionality and elevate the user experience, marking a step towards Ethereum's broader adoption.

## Conclusion

The synergy of Ethereum's account abstraction and the ERC-4337 standard marks a leap forward in smart contract wallet usability and security. It simplifies the user journey, introduces user-centric features, and fosters a more accessible, secure Web3 ecosystem. With account abstraction wallets like Argent and Braavos emerging, Ethereum spearheads a movement towards a user-focused decentralized future.

The accompanying diagram visualizes account abstraction, illustrating how UserOperation pseudo-transactions, facilitated by Bundlers, streamline transactions via the EntryPoint smart contract. This model negates the need for direct private key management, enhancing security and user experience.

Note: The diagram serves as a simplified illustration. Actual implementations may involve further complexities, though the foundational principles persist.
24 changes: 24 additions & 0 deletions docs/basics/account-abstraction/ercc4337.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: ERC 4337
sidebar_position: 2
---

## ERC-4337 Standard: Unlocking the Potential

Ethereum has introduced the ERC-4337 standard, co-authored by Vitalik Buterin and a team of experts, to facilitate account abstraction. This innovation empowers Smart Contract crypto wallets on EVM-based chains, broadening access and utility in the cryptocurrency domain.

## The Power of ERC-4337

The ERC-4337 standard presents a groundbreaking Account Abstraction proposal that circumvents the need for consensus-layer protocol modifications. It enables developers to craft custom Smart Contract Wallets with ease, paving the way for novel wallet functionalities.

Despite previous Ethereum Improvement Proposals (EIPs) concerning account abstraction, ERC-4337 stood out and was officially recognized in 2023. Its appeal lies in requiring no consensus-layer protocol adjustments.

How ERC-4337 Works: Introducing UserOperations

At the heart of ERC-4337 is the "UserOperation," a pseudo-transaction object stored within an alternative mempool ("Alt Mempool") on the network. Network nodes, dubbed "Bundlers," gather these UserOperations, consolidating them into a singular transaction known as a Bundle transaction.

This Bundle is then processed by a universal smart contract on the blockchain, the "EntryPoint." Notably, the blockchain hosts a single EntryPoint.

Bundlers engage the EntryPoint via the "handleOps" function, which authenticates signatures and manages gas fees through "validateUserOp" for each operation within the bundle. This mechanism shifts asset control away from private keys to programmable functions, streamlining the user experience by reducing the steps and confirmations required for transactions.

[image]
22 changes: 22 additions & 0 deletions docs/basics/account-abstraction/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Introduction
sidebar_position: 1
---

## Introduction

The adoption of Account Abstraction as a standard in EVM-based chains marks a significant advancement, facilitating the onboarding of the next billion users to Web3. This innovation has been integrated into the Fuse blockchain as well, which, being EVM compatible, ensures that features available on Ethereum are also accessible on Fuse.

A key distinction of the Fuse ecosystem is its higher Transactions Per Second (TPS) capability, leading to faster block times for transaction validation. With Account Abstraction, DApp developers on Fuse can now focus on their creations without worrying about the traditional challenges of onboarding Web2 users. These challenges often include a steep learning curve associated with managing non-custodial wallets, remembering private keys, or mnemonic seed phrases.

Powered by the FuseBox, Account Abstraction is enabled by default, facilitating the creation, management, and interaction with Smart Contract Wallets within client applications. These Smart Contract Wallets can be initiated using a user's Externally Owned Account (EOA) or via Social Authentication methods, offering enhanced security over traditional EOAs. Importantly, Smart Contract Wallets are non-custodial, allowing users complete control over their funds at any time.

The FuseBox, built on the Open Source Fuse Backend, simplifies the development process for creating and managing Smart Contract Wallets across REST API, Flutter, and TypeScript applications. It provides developers with pre-built functions and utilities to securely and efficiently develop applications powered by Account Abstraction.

### **Benefits of Using Account Abstraction on Fuse**

Account Abstraction on Fuse offers numerous advantages, such as::

- Enhanced security: Smart Contract Wallets, as non-custodial accounts, grant users exclusive control over their funds, with the wallet's smart contract only operable by the associated user.
- Improved User Experience: Supporting gasless transactions, Smart Contract Wallets facilitate a smoother interaction with blockchain applications, eliminating common barriers to entry.
- Better developer experience: The Fuse SDKs abstracts the complexities of web3 development, including cryptography, wallet management, and smart contract interactions, allowing developers to more easily create blockchain-based applications.
26 changes: 26 additions & 0 deletions docs/basics/account-abstraction/smart-contract-wallets.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Smart Contract Wallets
sidebar_position: 3
---

## Account Abstraction Wallets: A New Era of Wallet Design

Several account abstraction wallets have emerged with the implementation of account abstraction and the ERC-4337 standard. These wallets leverage the functionalities offered by smart contracts to provide users with a seamless and secure Web3 experience.

[List AA Wallets supported on Fuse]

## Benefits of Account Abstraction for Web3 Users

Account abstraction brings numerous benefits to the Web3 ecosystem, empowering users and enhancing the overall user experience. Let's explore some of the key advantages:

- Elimination of Seed Phrase Reliance
ERC-4337 enables secure wallets without the need for seed phrases, this eliminates the vulnerability associated with the loss or hacking of seed phrases, providing users with a more secure and convenient option. Additionally, ERC-4337 supports features such as two-factor authentication and biometrics, bringing familiarity and ease of use similar to traditional banking practices. These user-friendly features have the potential to boost adoption.

- Enhanced Security with Smart Contract Wallets
Incorporating smart contract wallets reduces the potential for human error, ensuring higher operational accuracy. With account abstraction, a user's private key is not directly used to control the assets within an account but is only used to authorize the execution of a smart contract. This improved security makes it harder for attackers to steal funds from specific accounts, promoting a safer Web3 environment.

- Seamless Compatibility across Diverse Blockchains
ERC-4337 allows easy adaptation across various blockchains compatible with the Ethereum Virtual Machine (EVM). Networks such as Polygon, Avalanche, Arbitrum, and others can leverage the advantages of account abstraction to offer users a consistent experience across different chains. This compatibility enhances interoperability and enables a more connected blockchain ecosystem.

- Shared Accounts and Multi-User Operations
Unlike EOAs, where full access to the crypto wallet is given or withheld, Account Abstraction wallets offer the flexibility to create multi-signature systems. This means that transactions can only be executed if two or more users sign them, providing an added layer of security and control. Account abstraction wallets open up possibilities for shared accounts and enable users to define specific permissions for different types of transactions, such as limiting payment permissions for a particular collection.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ To use the Fuse Flutter SDK in your project, you must create an instance of the

Whether you aim to fetch or create a smart wallet, relay an ERC20/FUSE transfer, relay an ERC721 transfer, relay a generic transaction, swap tokens, or stake tokens, the `FuseSDK` class has you covered. Additionally, the SDK provides data features that allow you to get the list of tokens owned by an address, get token details, and get a smart wallet's token balance.

The following code initializes the Fuse SDK and creates an instance of the `FuseSDK` class. The `publicApiKey` variable should be set to your own API key.
The following code initializes the Fuse SDK and creates an instance of the `FuseSDK` class. The `apiKey` variable should be set to your own API key.

```dart
import 'package:fuse_wallet_sdk/fuse_wallet_sdk.dart';

final apiKey = 'YOUR_PUBLIC_API_KEY';
final apiKey = 'API_KEY';
final privateKey = EthPrivateKey.fromHex('YOUR_PRIVATE_KEY');
final fuseSDK = await FuseSDK.init(apiKey, privateKey);
```
Expand Down
2 changes: 1 addition & 1 deletion docs/developers/fuse-box/flutter-sdk/19-sponsored-txn.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To use this feature, you must first initialize the SDK with the `withPaymaster`

```dart
import 'package:fuse_wallet_sdk/fuse_wallet_sdk.dart';
final apiKey = 'YOUR_PUBLIC_API_KEY';
final apiKey = 'API_KEY';
final privateKey = EthPrivateKey.fromHex('YOUR_PRIVATE_KEY');
final fuseSDK = await FuseSDK.init(apiKey, privateKey, withPaymaster: true);
```
6 changes: 3 additions & 3 deletions docs/developers/fuse-box/flutter-sdk/2-create-scw.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ sidebar_position: 2

### Initialization

The `init` method is a fundamental feature of the Fuse Wallet Flutter SDK that enables you to setup a wallet & authenticate the user's provided credentials. The method requires the use of a `PRIVATE_KEY` which you can get in the Fuse Developer Console [here](https://developers.fuse.io/). When you send a request to the server using this method, it verifies the credentials and if the credentials are valid, developers can use the **`getSender()`** to return an address.
The `init` method is a fundamental feature of the Fuse Wallet Flutter SDK that enables you to setup a wallet & authenticate the user's provided credentials. The method requires the use of a `PRIVATE_KEY` which you can get in the Fuse Developer Console [here](https://console.fuse.io/build). When you send a request to the server using this method, it verifies the credentials and if the credentials are valid, developers can use the **`getSender()`** to return an address.

```dart
//Enter your Fuse Developer API Key
final publicApiKey = 'YOUR_API_KEY';
final apiKey = 'API_KEY';

// Generate a random Ethereum private key
final String privateKey = await Mnemonic.generatePrivateKey();
final EthPrivateKey credentials = EthPrivateKey.fromHex(privateKey);

final fuseSDK = await FuseSDK.init(credentials);
final fuseSDK = await FuseSDK.init(apiKey, credentials);
```

### **Access the wallet**
Expand Down
14 changes: 7 additions & 7 deletions docs/developers/fuse-box/flutter-sdk/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ As we navigate through the details of this migration, we hope to provide you wit

Before embarking on this migration journey with the new `fuse_wallet_sdk`, the process is made delightfully simple for our users. However, there's a minimal requirement you should be aware of:

- **API Key**: The only prerequisite to utilize the updated SDK is to have a valid API key. If you haven't create one yet or need a new one, don't fret! Simply head over to our Developer's Console at https://developers.fuse.io/ and follow the straightforward steps to obtain your key.
- **API Key**: The only prerequisite to utilize the updated SDK is to have a valid API key. If you haven't create one yet or need a new one, don't fret! Simply head over to our Developer's Console at https://console.fuse.io/build and follow the straightforward steps to obtain your key.

With your API key in hand, you're all set to integrate and experience the enhanced capabilities of the `fuse_wallet_sdk`.

Expand All @@ -44,13 +44,13 @@ Identify and remove the following sections from your old SDK code:
Replace the old initialization:

```dart
final FuseWalletSDK fuseWalletSDK = FuseWalletSDK(publicApiKey);
final FuseWalletSDK fuseWalletSDK = FuseWalletSDK(apiKey);
```

with the new one:

```dart
final fuseSDK = await FuseSDK.init(publicApiKey, credentials);
final fuseSDK = await FuseSDK.init(apiKey, credentials);
```

4. **Access the Smart Contract Wallet Address**:
Expand Down Expand Up @@ -116,7 +116,7 @@ import 'package:charge_wallet_sdk/charge_wallet_sdk.dart';

void main() async {
// Your public API key (<https://chargeweb3.com>)
final String PUBLIC_API_KEY = 'YOUR_PUBLIC_API_KEY';
final String apiKey = 'API_KEY';

// generate mnemonic
String mnemonic = Web3.generateMnemonic();
Expand All @@ -137,7 +137,7 @@ void main() async {
print('account address: $accountAddress');

// init api module
ChargeApi chargeApi = ChargeApi(PUBLIC_API_KEY);
ChargeApi chargeApi = ChargeApi(apiKey);

// login
print('enter phone number and press ENTER');
Expand Down Expand Up @@ -198,7 +198,7 @@ import 'package:fuse/fuse_wallet_sdk.dart';

void main() async {
// Create a project: https://chargeweb3.com
final String publicApiKey = 'YOUR_PUBLIC_API_KEY';
final String apiKey = 'YOUR_PUBLIC_API_KEY';

print('Enter privateKey:');
String privateKey =
Expand All @@ -209,7 +209,7 @@ void main() async {
print('address: ${credentials.address.hexEip55}');

// Initialize FuseWalletSDK
final FuseWalletSDK fuseWalletSDK = FuseWalletSDK(publicApiKey);
final FuseWalletSDK fuseWalletSDK = FuseWalletSDK(apiKey);
final DC<Exception, String> authRes = await fuseWalletSDK.authenticate(
credentials,
);
Expand Down
8 changes: 4 additions & 4 deletions docs/developers/fuse-box/fuse-sdk/create-scw.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar_position: 5

### Create a Smart Contract Wallet

The `init` method is a fundamental feature of the FuseBox JS SDK that enables you to setup a wallet by parsing the `PRIVATE_KEY` from an EOA. In the example below, we parse the `PRIVATE_KEY` and `YOUR_API_KEY` to the `init` method. Get `YOUR_API_KEY` [here](https://developers.fuse.io/). We use the `EthersJS` library to access the `PRIVATE_KEY` of the EOA. After a Smart Contract Wallet has been initialized, we can read it using the `getSender()` method.
The `init` method is a fundamental feature of the FuseBox JS SDK that enables you to setup a wallet by parsing the `PRIVATE_KEY` from an EOA. In the example below, we parse the `PRIVATE_KEY` and `API_KEY` to the `init` method. Get `API_KEY` [here](https://console.fuse.io/build). We use the `EthersJS` library to access the `PRIVATE_KEY` of the EOA. After a Smart Contract Wallet has been initialized, we can read it using the `getSender()` method.

Note: Developers can use the EthersJS `createRandom()` to create new random Wallets.

Expand All @@ -14,10 +14,10 @@ import { ethers } from "ethers";
import { FuseSDK } from "@fuseio/fusebox-web-sdk";

const main = async () => {
const publicApiKey = "YOUR_API_KEY" as string;
const credentials = new ethers.Wallet("PRIVATE_KEY" as string);
const apiKey = "API_KEY";
const credentials = new ethers.Wallet("PRIVATE_KEY");

const fuse = await FuseSDK.init(publicApiKey, credentials);
const fuse = await FuseSDK.init(apiKey, credentials);

console.log(`Sender Address is ${fuseSDK.wallet.getSender()}`);
};
Expand Down
12 changes: 6 additions & 6 deletions docs/developers/fuse-box/fuse-sdk/installation-and-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ Using the SDK requires the use of the `EthersJS` library. We require the `Ethers
npm install ethers
```

The following code initializes the Fuse SDK and creates an instance of the `FuseSDK` class. The `publicApiKey` variable should be set to your own API key.
The following code initializes the Fuse SDK and creates an instance of the `FuseSDK` class. The `apiKey` variable should be set to your own API key.

Replace `YOUR_API_KEY` with your actual API key obtained from the Fuse [Developer](https://developers.fuse.io/) Dashboard.
Replace `API_KEY` with your actual API key obtained from the Fuse [Developer](https://console.fuse.io/build) Dashboard.
To enable `Paymaster`, set it as the third argument in the `init()` method. `withPaymaster: true` . It is default `false` where the argument is not provided.

```javascript
import { ethers } from 'ethers';
import { FuseSDK } from '@fuseio/fuse-web-sdk';
import { FuseSDK } from '@fuseio/fusebox-web-sdk';

const publicApiKey = 'YOUR_API_KEY';
const credentials = new ethers.Wallet(process.env.PRIVATE_KEY as string);
const fuse = await FuseSDK.init(publicApiKey, credentials);
const apiKey = 'API_KEY';
const credentials = new ethers.Wallet("PRIVATE_KEY");
const fuse = await FuseSDK.init(apiKey, credentials);
```

Once you have created an instance of the `FuseSDK` class, you can use its instance methods to interact with the Fuse API. In the following section, we will cover the available methods of the SDK.
4 changes: 2 additions & 2 deletions docs/developers/fuse-box/fuse-sdk/paymaster.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ To use this feature, you must first initialize the SDK with the _`withPaymaster`
```javascript
import { FuseSDK } from "@fuseio/fusebox-web-sdk";

const publicApiKey = "YOUR_API_KEY";
const fuseSDK = await FuseSDK.init(publicApiKey, credentials, {
const apiKey = "API_KEY";
const fuseSDK = await FuseSDK.init(apiKey, credentials, {
withPaymaster: true,
});
```
6 changes: 3 additions & 3 deletions docs/developers/fuse-box/fuse-sdk/send-batch-txn.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import { ethers } from "ethers";
import { FuseSDK } from "@fuseio/fusebox-web-sdk";

const main = async () => {
const credentials = new ethers.Wallet("PRIVATE_KEY" as string);
const publicApiKey = "YOUR_API_KEY" as string;
const fuseSDK = await FuseSDK.init(publicApiKey, credentials);
const credentials = new ethers.Wallet("PRIVATE_KEY");
const apiKey = "API_KEY";
const fuseSDK = await FuseSDK.init(apiKey, credentials);

console.log(`Sender Address is ${fuseSDK.wallet.getSender()}`);

Expand Down
6 changes: 3 additions & 3 deletions docs/developers/fuse-box/fuse-sdk/send-single-txn.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import { ethers } from "ethers";
import { FuseSDK } from "@fuseio/fusebox-web-sdk";

const main = async () => {
const credentials = new ethers.Wallet("PRIVATE_KEY" as string);
const publicApiKey = "pk_wEP0gTlc3jcvBXEDpSnXBgbQ" as string;
const fuseSDK = await FuseSDK.init(publicApiKey, credentials);
const credentials = new ethers.Wallet("PRIVATE_KEY");
const apiKey = "API_KEY";
const fuseSDK = await FuseSDK.init(apiKey, credentials);

console.log(`Sender Address is ${fuseSDK.wallet.getSender()}`);

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.