First Signing Flow
Minimal Flutter signing pipeline:
- Resolve sender address
- Calculate fees
- Build pre-image
- Sign
Example
import 'package:blockchain_kit_sdk_flutter_plugin/blockchain_kit_sdk_flutter_plugin.dart';
final sdk = BlockchainKitSdk();
const groupId = 'YOUR_GROUP_ID';
final network = Network(
'ethereum-mainnet',
'Ethereum Mainnet',
NetworkType.EVM,
BigInt.from(1),
RpcConfig('https://rpc.ankr.com/eth'),
EvmFeatures(true, true, true, true, false),
null,
null,
null,
NativeCurrency('Ether', 'ETH', 18),
Explorer('https://etherscan.io/tx/', 'https://etherscan.io/address/'),
);
final asset = NativeCoin(network, null);
// 1) Address
final addressResult = await sdk.blockchainService.getAddress(asset, groupId);
await addressResult.fold((fromAddress) async {
// 2) Build transaction intent
final tx = Transfer(
asset,
BigInt.from(1000000000000000), // 0.001 ETH in wei
'0x1111111111111111111111111111111111111111',
false,
null,
);
// 3) Fees
final feeResult = await sdk.blockchainService.calculateFees(tx, fromAddress);
await feeResult.fold((fee) async {
// 4) Pre-image + sign
final preImageResult = await sdk.blockchainService.preImageHash(tx, fromAddress, fee);
await preImageResult.fold((preImage) async {
final signResult = await sdk.blockchainService.sign(preImage, groupId);
signResult.fold(
(signedTxHex) => print('Signed tx hex: $signedTxHex'),
(error) => print('Sign failed: ${error.message}'),
);
}, (error) async {
print('Pre-image failed: ${error.message}');
});
}, (error) async {
print('Fee calc failed: ${error.message}');
});
}, (error) async {
print('Address resolution failed: ${error.message}');
});
Notes
- This example signs but does not broadcast.
- To broadcast, call
sdk.blockchainService.sendTransaction(network, signedTxHex).