pascaldart 2.0.0 copy "pascaldart: ^2.0.0" to clipboard
pascaldart: ^2.0.0 copied to clipboard

A dart library for PascalCoin. Supports key generation, encoding, encryption/decryption, signing, RPC.

example/pascaldart_example.dart

import 'dart:typed_data';

import 'package:pascaldart/pascaldart.dart';

main() async {
  // Generating a keypair
  KeyPair kp = Keys.generate(curve: Curve.getDefaultCurve());
  // RPC client
  RPCClient rpc = RPCClient(rpcAddress: 'http://127.0.0.1:4003');
  // Creating transaction operation and signing it
  TransactionOperation op = TransactionOperation(
      sender: AccountNumber.fromInt(1234),
      target: AccountNumber.fromInt(1000),
      amount: Currency('10'))
    ..withNOperation(2)
    ..withPayload(PDUtil.stringToBytesUtf8('Hello Payload'))
    ..withFee(Currency('0'))
    ..sign(kp.privateKey);
  // Executing operation
  Uint8List encodedRawOp = RawOperationCoder.encodeToBytes(op);
  ExecuteOperationsRequest request =
      ExecuteOperationsRequest(rawOperations: PDUtil.byteToHex(encodedRawOp));
  RPCResponse rawResp = await rpc.makeRpcRequest(request);
  if (rawResp.isError) {
    // Handling an error
    ErrorResponse errResp = rawResp as ErrorResponse;
    print(errResp.errorMessage);
  } else {
    OperationsResponse opResp = rawResp as OperationsResponse;
    opResp.operations!.forEach((op) {
      print(op.amount!.toStringOpt());
    });
  }
}
0
likes
110
pub points
52%
popularity

Publisher

verified publisherappditto.com

A dart library for PascalCoin. Supports key generation, encoding, encryption/decryption, signing, RPC.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

collection, hex, http, json_annotation, meta, pointycastle, quiver

More

Packages that depend on pascaldart