init static method
Future<FuseSDK>
init(
- String publicApiKey,
- EthPrivateKey credentials, {
- String baseUrl = Variables.BASE_URL,
- bool withPaymaster = false,
- Map<
String, dynamic> ? paymasterContext, - IPresetBuilderOpts? opts,
- IClientOpts? clientOpts,
Initializes the SDK.
publicApiKey
is required to authenticate with the Fuse API.
credentials
are the Ethereum private key credentials.
withPaymaster
indicates if the paymaster should be used.
paymasterContext
provides additional context for the paymaster.
opts
are the preset builder options.
clientOpts
are the client options.
Implementation
static Future<FuseSDK> init(
String publicApiKey,
EthPrivateKey credentials, {
String baseUrl = Variables.BASE_URL,
bool withPaymaster = false,
Map<String, dynamic>? paymasterContext,
IPresetBuilderOpts? opts,
IClientOpts? clientOpts,
}) async {
final fuseSDK = FuseSDK(publicApiKey, baseUrl: baseUrl);
UserOperationMiddlewareFn? paymasterMiddleware;
if (withPaymaster) {
paymasterMiddleware = _getPaymasterMiddleware(
publicApiKey,
baseUrl,
paymasterContext,
);
}
fuseSDK.wallet = await _initializeWallet(
credentials,
publicApiKey,
baseUrl,
opts,
paymasterMiddleware,
);
await fuseSDK.authenticate(credentials);
fuseSDK.client = await Client.init(
_getBundlerRpc(publicApiKey: publicApiKey, baseUrl: baseUrl),
opts: clientOpts,
);
return fuseSDK;
}