flutter_algosigner

Last updated:

0 purchases

flutter_algosigner Image
flutter_algosigner Images
Add to Cart

Description:

flutter algosigner

flutter-algosigner #





AlgoSigner is a blockchain wallet that makes it easy to use Algorand-based applications on the web. Simply create or import your Algorand account, visit a compatible dApp, and approve or deny transactions — all from within your browser.
AlgoSigner opens the door for developers to build DeFi applications on Algorand by providing a secure way to add transaction capabilities. This enables developers to initiate transactions and accept ALGOs seamlessly, without jeopardizing the security of their users’ secrets.
DApp users can trust AlgoSigner to:

Securely store and encrypt account secrets
Authorize transactions without giving dApps direct access to their keys
Sign and approve transactions when using dApps

The plugin was developed by RootSoft and is not affiliated with PureStake or AlgoSigner is any way. For more information, check out the official AlgoSigner documentation.
Introduction #
AlgoSigner injects a JavaScript library into every web page the browser user visits, which allows the site to interact with the extension. The dApp can use the injected library to connect to the user's Wallet, discover account addresses it holds, query the Network (make calls to AlgoD v2 or the Indexer) and request AlgoSigner to request for the user to sign a transaction initiated by the application. All methods of the injected library return a Future that needs to be handled by the dApp.
The flutter-algosigner plugin follows the AlgoSigner API closely and all methods are available. The plugin integrates elegantly with the algorand_dart SDK so transactions can be easily signed and approved.
Once installed, you can simply sign transactions and start sending payments:
await AlgoSigner.connect();

/// Sign the transaction
final txs = await AlgoSigner.signTransaction(
{
'txn': transaction.toBase64(),
},
);

// Send the transaction
final txId = await AlgoSigner.send(
ledger: 'TestNet',
transaction: blob,
);
copied to clipboard
Getting started #
Installation #
You can install the package via pub.dev:
flutter pub add flutter_algosigner
copied to clipboard
This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):
dependencies:
flutter_algosigner: ^latest-version
copied to clipboard
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
Methods #
The flutter-algosigner web plugin wraps the JavaScript API and exposes methods for Flutter developers. This way, Flutter web developers can benefit and create web3 dApplications using the same API.
connect() #
Requests access to the Wallet for the dApp, may be rejected or approved. Every access to the extension begins with a connect request, which if approved by the user, allows the dApp to follow-up with other requests.
await AlgoSigner.connect();
copied to clipboard
accounts() #
Returns an array of accounts present in the Wallet for the given Network.
final accounts = await AlgoSigner.accounts(ledger: 'TestNet');
copied to clipboard
algod() #
Proxies the requested path to the Algod v2 API. Is limited to endpoints made available by the API server. By default, all calls to the AlgoSigner.algod method are GET.
await AlgoSigner.algod(
ledger: 'TestNet',
path: '/v2/transactions/params',
);
copied to clipboard
To make a POST requests, more details need to be included in as input.
await AlgoSigner.algod(
ledger: 'TestNet',
path: '/v2/teal/compile',
body: 'int 0',
method: 'POST',
contentType: 'text/plain',
);
copied to clipboard
indexer() #
Proxies the requested path to the Indexer v2 API. Is limited to endpoints made available by the API server. The API backend may be configured by advanced users and is not guaranteed to respond as expected. More information can be found here.
await AlgoSigner.indexer(
ledger: 'TestNet',
path: '/v2/assets/150821',
);
copied to clipboard
signTransaction() #
Send transaction objects, conforming to the Algorand JS SDK, to AlgoSigner for approval. The Network is determined from the 'genesis-id' property. If approved, the response is an array of signed transaction objects, with the binary blob field base64 encoded to prevent transmission issues.
Transaction Requirements
Transactions objects need to be presented with the following structure:
{
txn: Base64-encoded string of a transaction binary,
signers?: [optional] array of addresses to sign with (defaults to the sender),
multisig?: [optional] extra metadata needed for multisig transactions,
};
copied to clipboard
For more information, see the transaction requirements
Request
await AlgoSigner.signTransactions(
[
{
'txn': transaction.toBase64(),
},
],
);
copied to clipboard
Example
The following displays an example on how the algorand-dart SDK can be used to sign transactions with AlgoSigner.
await AlgoSigner.connect();

// Fetch the suggested transaction params
final params = await algorand.getSuggestedTransactionParams();

// Build the transaction
final transaction = await (PaymentTransactionBuilder()
..sender = address
..note = 'Hi from Flutter'
..amount = Algo.toMicroAlgos(0.1)
..receiver = address
..suggestedParams = params)
.build();

final txs = await AlgoSigner.signTransactions(
[
{
'txn': transaction.toBase64(),
},
],
);

final blob = txs[0]['blob'];
copied to clipboard
send() #
Send a base64 encoded signed transaction blob to AlgoSigner to transmit to the Network.
final txId = await AlgoSigner.send(
ledger: 'TestNet',
transaction: blob,
);

final tx = await algorand.waitForConfirmation(txId);
copied to clipboard
Changelog #
Please see CHANGELOG for more information on what has changed recently.
Contributing & Pull Requests #
Feel free to send pull requests.
Please see CONTRIBUTING for details.
Credits #

Tomas Verhelst
All Contributors

License #
The MIT License (MIT). Please see License File for more information.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.