Skip to main content

How to use Flutter SDK

Key Management

import 'package:web3_cloud_sdk/client_sdk.dart' as clientsdk;
import 'package:web3_cloud_sdk/ethereum_lib.dart' as ethereum;

// Generate Mnemonic
await clientsdk.generateMnemonic(String walletId, int strength);

// Get Mnemonic
String mnemonic = await clientsdk.getMnemonic(String walletId);

// Import Mnemonic
await clientsdk.importMnemonic(String walletId, String mnemonic);

// Destroy Mnemonic
await clientsdk.destroyMnemonic(String walletId);

Wallet

import 'package:web3_cloud_sdk/client_sdk.dart' as clientsdk;
import 'package:web3_cloud_sdk/ethereum_lib.dart' as ethereum;

clientsdk.SdkBase sdk = clientsdk.SdkBase();
ethereum.NetworkParam networkParam = ethereum.NetworkParam(int chainId, int networkId,String rpcUrl);

// Create Wallet
ethereum.Wallet wallet = await sdk.evm.createWallet(String walletId, ethereum.NetworkParam networkParam);

// Derive Private Key
String privateKey = await wallet
.account(int index)
.getPrivateKey();

// Derive Address
String address = await wallet
.account(int index)
.address();

// Get ETH Balance
String balance = await wallet
.account(int index)
.balance();

// Get FT Balance
String balance = await wallet
.account(int index)
.ftBalance(String contractAddress);

Transaction

// Create & Sign Transaction
String signedTx = await ethereum.TxBuilder()
.value(String value)
.gasPrice(String gasPrice)
.gasLimit(int gasLimit)
.to(String toAddress)
.chainId(int chainId)
.sign(wallet.account(int index))
.build();

// Submit transaction
String txHash = await wallet.web3.sendTransaction(String signedTx);
info

Interface is still being actively developed and might be subject to change