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 #144

Merged
merged 9 commits into from
Mar 4, 2024
7 changes: 3 additions & 4 deletions docs/basics/Voltage-Finance-bridge-FuseBNB-Chain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ This is a step-by-step guide explaining how to move BEP20-supported tokens betwe

In this step-by-step bridging tutorial, we will use a [MetaMask wallet](https://metamask.io/download/) to bridge FUSE tokens from **Fuse** to the \*\*BSC network \*\*via the native [app.voltage.finance](https://app.voltage.finance/#/bridge) bridge.

<Admonition type="info" title="Note">
:::note
Make sure you are connected to the Fuse Network RPC. To learn how to add the
Fuse Network RPC you can follow the tutorial
[here](https://docs.fuse.io/docs/tutorials/network-tutorials/tutorialsOverview)
</Admonition>
Fuse Network RPC you can follow the [tutorial](../basics/guides/tutorialsOverview)
:::

**Step 1:** Navigate to[ ](https://fuseswap.com/)[app.voltage.finance/#/bridge](https://app.voltage.finance/#/bridge):

Expand Down
2 changes: 1 addition & 1 deletion docs/basics/intro-to-fuse/fuse-consensus.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The need to stake Fuse ensures that an entity cannot create multiple seemingly d

The validator who publishes a block agreed upon during a consensus round is rewarded by the network protocol in newly minted FUSE tokens. They also receive the fees users pay for the transactions included in the block.

Over time, validators can expect to publish a share of blocks equal to their overall stake. Since FUSE uses dPoS, a validator can increase their share by attracting FUSE tokens from delegators. The mechanics of delegation on FUSE are discussed in more detail on the [following page](https://docs.fuse.io/aboutFuse/about-fuse/fuse-network-blockchain/validators-and-delegation).
Over time, validators can expect to publish a share of blocks equal to their overall stake. Since FUSE uses dPoS, a validator can increase their share by attracting FUSE tokens from delegators.

## Misbehaving and malfunctioning

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Governance is currently split among the following actors:

**1) Network Validators.** Fuse Network validators are entrusted with deciding whether to adopt [Fuse improvement proposals](./fips.mdx) (FIPs). Regardless of their share of the overall network stake, every validator has one vote, but this will likely change soon.

**2) Fuse Foundation and the project team.** Like most public blockchain projects at the initial stage of development, the development of the core network protocol and the Fuse treasury that primarily consists of the undistributed genesis FUSE supply (see the subsection "[FUSE Supply and Current Distribution](https://docs.fuse.io/general/fuse-token/fuse-supply-and-current-distribution)") are currently managed mainly by a foundation.
**2) Fuse Foundation and the project team.** Like most public blockchain projects at the initial stage of development, the development of the core network protocol and the Fuse treasury that primarily consists of the undistributed genesis FUSE supply are currently managed mainly by a foundation.

For Fuse, this role is played by Gibraltar-incorporated company Fuse Network Limited. Fuse Foundation employs the Fuse project team, whose members' profiles can be found [here](https://fuse.io/about).

Expand All @@ -21,4 +21,4 @@ It also boosts the network's adoption by improving the Fuse tech stack, securing

Since Fuse is a decentralized public blockchain platform, no permission from the project team is required for anyone who wishes to integrate with or develop on top of Fuse, including the network and node software development.

3\) Fuse Assembly. See the Assembly [page](https://docs.fuse.io/general/fuse-governance/fuse-assembly) for more details.
3\) Fuse Assembly. See the [Assembly page](../fuse-governance-and-development/fuse-assembly) for more details.
21 changes: 8 additions & 13 deletions docs/developers/Quick-Start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Welcome to the Fuse Blockchain Developer Quick Start Guide! This guide is design

### Creating a Fuse Wallet

To interact with the Fuse Blockchain, you'll need a wallet. Follow the [Fuse Metamask guide](https://docs.fuse.io/fuse-wallet/create-fuse-wallet) to set up your wallet.
To interact with the Fuse Blockchain, you'll need a wallet. Follow the [Fuse Metamask guide](../basics/guides/tutorialsOverview) to set up your wallet.


### Choosing a Development Option

Expand All @@ -48,29 +49,23 @@ Fuse provides a set of APIs for building on the Fuse blockchain, and also a Web

### Writing and Deploying Smart Contracts

Follow the [smart contract development guide](https://docs.fuse.io/fuse-studio/smart-contracts) for step-by-step instructions on writing and deploying smart contracts on Fuse.

You can use Remix IDE, Hardhat, and/or ThirdWeb to deploy and test your smart contracts. Refer to the [smart contract deployment guide](https://docs.fuse.io/fuse-studio/smart-contracts) for step-by-step instructions.

Get familiar with Fuse smart contract concepts, including token creation, staking, and governance. Refer to the [smart contract guide](https://docs.fuse.io/fuse-studio/smart-contracts) for in-depth information.
You can use [Remix IDE](../developers/deploying-smart-contracts/using-remix-and-metamask), [Hardhat](../developers/deploying-smart-contracts/using-hardhat), and/or [ThirdWeb](../developers/deploying-smart-contracts/using-thirdweb) to deploy and test your smart contracts.

Learn how to interact with smart contracts using web3 libraries. Fuse supports Ethereum-compatible libraries like Web3.js and ethers.js.

<p>&nbsp;</p>

## Fuse Developer Tools

### Fuse API Documentation

Refer to the [Fuse API documentation](https://docs.fuse.io/api) for comprehensive information on Fuse APIs, endpoints, and integration guides.

### FuseBox

Visit the [Fuse developer portal](https://developer.fuse.io/) for additional resources, tutorials, and community support.
[Create your project](https://console.fuse.io/build) to access FuseBox APIs.

### SDK (Both TS & Dart)

### Flutter SDK
Fuse provides a variety of tools and SDKs to enhance your development experience.

Fuse provides a variety of tools and SDKs to enhance your development experience. Explore the [Fuse GitHub repository](https://github.com/fuseio) for the latest tools and libraries.
[Fuse API documentation](../fuse-box/fuse-apis/api-introduction) for comprehensive information on FuseBox APIs, endpoints, and tutorials.

<p>&nbsp;</p>

Expand Down
201 changes: 201 additions & 0 deletions docs/fuse-box/tutorials/mobile-guide-transfers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
---
title: Handling Transfers Using the Fuse Wallet SDK in a Flutter App
sidebar_position: 9
---

## Pre-requites:
- Basic knowledge of Dart/Flutter
- An API Key from [Console](https://console.fuse.io/build)
- PrivateKEY from an Externally Owned Account (EOA)

## Step 1: Set Up Your Flutter Project
Create a new Flutter project using the following command:

```bash
flutter create fuse_wallet_app
cd fuse_wallet_app
```

Open the project in your favorite code editor, such as VSCode and run it using:

```bash
flutter run
```
You will find the default app running.

## Step 2: Add Dependencies
In your pubspec.yaml file, add the required dependencies:

```yaml
dependencies:
fuse_wallet_sdk: ^0.3.1
flutter_hooks: ^0.23.0
```

Run flutter pub get to install the dependencies.

## Step 3: Implement the Wallet Creation Screen

Open your Flutter project and open the default Dart file in the `lib` dir of your app, `main.dart`. Update it with the following code:



```dart
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:fuse_wallet_sdk/fuse_wallet_sdk.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Smart Contract Wallet',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: WalletCreationScreen(),
);
}
}


class WalletCreationScreen extends HookWidget {
@override
Widget build(BuildContext context) {
final createWallet = useState<String?>(null);

Future<void> _createSmartContractWallet() async {
const apiKey = 'pk_KEY';
final privateKey = EthPrivateKey.fromHex('0xEOA_PRIVATE_KEY');

try {
final fuseSDK = await FuseSDK.init(apiKey, privateKey);
String address = fuseSDK.wallet.getSender();

createWallet.value = address;
print('Smart contract wallet address: ${createWallet.value}');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TransferScreen(fuseSDK: fuseSDK, walletAddress: address),
),
);
} catch (e) {
// Handle initialization error
print('Error during wallet creation: $e');
}
}

return Scaffold(
appBar: AppBar(
title: Text('FuseBox Mobile App'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () {
_createSmartContractWallet();
},
child: Text('Create Smart Contract Wallet'),
),
SizedBox(height: 20),
if (createWallet.value != null)
Text('Wallet Address: ${createWallet.value}'),

],
),
),
);
}
}
```
In the Screen above, we implemented a Basic Screen when you can click a Button, and create a Smart Contract Wallet. The screen navigates to a Transfer Screen where the created Smart Contract Wallet is displayed.

## Step 4: Implement the Transfer
Create a new file named transfer_screen.dart and implement the Transfer Screen.

```dart
class TransferScreen extends HookWidget {
final FuseSDK fuseSDK;
final String walletAddress;


TransferScreen({required this.fuseSDK, required this.walletAddress});

Future<void> _transferFunds() async {
try {
final res = await fuseSDK.transferToken(
EthereumAddress.fromHex('0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'), // Replace with your token address
EthereumAddress.fromHex('0xd8da6bf26964af9d7eed9e03e53415d37aa96045'), // for 'vitalik.eth'. Replace with recipient's address.
BigInt.parse('1000000000000000000'), // Replace with the amount in Wei
);

print('UserOpHash: ${res.userOpHash}');
print('Waiting for transaction...');

final ev = await res.wait();
print('Transaction successful... Hash ${ev}');
// Handle success, you can show a success message or navigate to another screen
} catch (e) {
// Handle the error, you can show an error message or log it
print('Error during transfer: $e');
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Transfer Screen'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,

children: <Widget>[
Text('Wallet Address: ${walletAddress}'),
Text('Transfer funds here'),
ElevatedButton(
onPressed: () {
_transferFunds();
},
child: Text('Transfer Funds'),
),
],
),
),
);
}
}
```

Run your app using:
```bash
flutter run
```

You should now have a basic Flutter app that allows users to create a Smart Contract Wallet and perform token transfers using the Fuse Wallet SDK. Please replace the placeholder values with your actual API key, private key, token address, recipient address, and transfer amount.

## Conclusion
In this tutorial, we've created a simple Flutter app that leverages the Fuse Wallet SDK to demonstrate the process of creating a Smart Contract Wallet and initiating a token transfer on the Fuse Blockchain. While this example serves as a basic introduction to integrating blockchain functionality into a mobile app, developers can expand upon this foundation to build more robust and feature-rich applications.

### Use Cases for Expansion
- User Authentication and Security: Enhance the app by implementing authentication mechanisms to secure user accounts and wallet access. Integrate biometrics or PIN-based authentication for an added layer of security.

- Token Balance and Transaction History: Extend the app to display the user's token balance and transaction history. Utilize the Fuse Wallet SDK's functionalities to retrieve and present this information in a user-friendly manner.

- Advanced Token Transfer Features: Explore advanced token transfer features such as handling different token types, adding transfer notes, or implementing recurring transfers. This can enhance the app's versatility for various use cases.

- Integration with External APIs: Integrate the app with external APIs or services to retrieve real-time market data, token prices, or additional information relevant to the user's financial activities.

- Smart Contract Interactions: Explore smart contract interactions beyond simple transfers. Implement features like voting, decentralized finance (DeFi) integrations, or participation in decentralized applications (DApps).

Remember, this example is a starting point, and developers can tailor the app to meet specific use cases and business requirements. Fuse Wallet SDK provides a powerful toolkit to explore various blockchain-related functionalities, and integrating these features can result in a versatile and powerful mobile app for users interested in decentralized finance and blockchain technology.


4 changes: 2 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ const config = {
to: "https://explorer.fuse.io/",
},
{
label: "Documentation",
to: "https://docs.fuse.io/",
label: "Bridge",
to: "https://console.fuse.io/bridge",
},
{
label: "Staking",
Expand Down