-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Flutter SDK | ||
|
||
With the Flutter SDK, you can add functionality to buttons in your app to interact with a vault contract. You only need **three lines of code** to set up a vault and perform actions like deposits! Here’s how to use it: | ||
|
||
1. **Obtain the Vault Contract Address:** You need the contract address for the vault where you want users to deposit. This can be got from the Dapp | ||
|
||
2. **Create a Vault Instance:** Set up an instance of the vault in your code. | ||
|
||
3. **Use Vault Functions:** Call `vault.deposit`, `vault.balance`, or `vault.withdraw` as needed. | ||
|
||
## Example Code | ||
|
||
Below is an example showing how to create a vault instance and call the `deposit` function: | ||
|
||
```dart | ||
import 'package:defindex_sdk/defindex_sdk.dart'; | ||
// Create a vault instance | ||
var vault = Vault( | ||
sorobanRPCUrl: 'https://soroban-testnet.stellar.org', | ||
network: SorobanNetwork.TESTNET, | ||
contractId: 'CD76H2IVRMRMLE4KZXLAVK3L3CO7PENUB3X4VB2FQVUAFVAJMQYQIFDE', | ||
); | ||
// Make a deposit | ||
String? transactionHash = await vault.deposit( | ||
'GCW36WQUHJASZVNFIIL7VZQWL6Q72XT6TAU6N3XMFGTLSNE2L7LMJNWT', // User's Stellar address | ||
100.0, // Amount to deposit | ||
(transaction) async => signerFunction(transaction), | ||
); | ||
print('Transaction hash: $transactionHash'); | ||
// Optionally, show a dialog or snackbar with the result | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
SnackBar(content: Text('Transaction hash: $transactionHash')), | ||
); |