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

outdated

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;
    print(errResp.errorMessage);
  } else {
    OperationsResponse opResp = rawResp;
    opResp.operations.forEach((op) {
      print(op.amount.toStringOpt());
    });
  }
}
0
likes
0
points
91
downloads

Publisher

verified publisherappditto.com

Weekly Downloads

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

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

More

Packages that depend on pascaldart