run method

  1. @override
Future<void> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<void> run() async {
  final accountClassHash = Felt.fromHexString(
    '0x0251cac7b2f45d255b83b7a06dcdef70c8a8752f00ea776517c1c2243c7a06e5',
  ); // Focus Account
  final publicKey = Felt.fromHexString(
    globalResults?['public-key'] as String,
  );
  final privateKey = Felt.fromHexString(
    globalResults?['private-key'] as String,
  );
  final signer = StarkSigner(privateKey: privateKey);
  final accountAddress = Contract.computeAddress(
    classHash: accountClassHash,
    calldata: [signer.publicKey],
    salt: signer.publicKey,
  );
  stdout.writeln('Account address: ${accountAddress.toHexString()}');

  final res = await Account.deployAccount(
    accountSigner: signerFromArgs(globalResults),
    provider: providerFromArgs(globalResults),
    constructorCalldata: [publicKey],
    classHash: accountClassHash,
  );

  stdout.writeln(
    res.when(
      result: (result) => result.contractAddress.toHexString(),
      error: (error) => throw Exception(error),
    ),
  );
}