sendTransactionWithPK()

Send a new transaction on the blockchain. This method automatically calculates the signature, nonce, and other parameters.

Method Signature

Future<dynamic> sendTransactionWithPK(
      String from,
      String privateKey,
      String to,
      String type,
      Map<String, String> payload,
      String blockchain);

Type:

Types of transactions:

  • C_TYPE_COIN: Transaction involving native coins (CIRX) without the use of Hyper Code (Smart Contracts).

  • C_TYPE_TOKEN: Transaction involving specified tokens without the use of Hyper Code.

  • C_TYPE_ASSET: Transaction involving a generic digital asset that is not represented by a token.

  • C_TYPE_CERTIFICATE: Transaction where the payload doesn't require processing and is a generic string.

  • C_TYPE_REGISTERWALLET: Transaction used to register a new wallet on a specified blockchain.

  • C_TYPE_HC_DEPLOYMENT: Transaction to deploy a new Hyper Code Program.

  • C_TYPE_HC_REQUEST: Transaction to call a specified endpoint of a Hyper Program.

  • C_TYPE_USERDEF: Unspecified type, defined by the user (not available yet).

Parameters

Example

import 'package:circular_api/circular_api.dart';

void main() async{
    final circular = CircularAPI();
    final blockhain = "0x8a20baa40c45dc5055aeb26197c203e576ef389d9acb171bd62da11dc5ad72b2";
    final from = "0x8b20bda40c45dc2908aeb26197c203e576ef389d9acb171bd62da15af5ad72b4";
    final to = "0x9a20bda40c45dc2908aeb26197c2bde576ad389d9acb181bd62da15af5adaf32";
    final privateKey = "receiver = 0x1f22bda40c45dc2908aeb26197c2bde576ad332d9dcb451bd62da15af5adaa40";
    final type = "C_TYPE_COIN";
    final payload = {
        "Asset": "CIRX",
        "Amount" : 100,
        "Action" : "CP_SEND",
        "Memo" : "Test memo"
    }
    
    final result = await circular.sendTransactionWithPK(from, privateKey, to, type, payload, blockchain);
}

Result

{
  "Result": 200,
  "Response": {
    "TxID": "138dd7a19685c71f281d8f5b9d0de15dc7ce7e9433e1715ec6e45e0fade74c82",
    "Timestamp": "2024:09:26-21:57:12"
  },
  "Node": "8a93c6b6f8d166097ddfeb3e5e3a2998b35e0b6f0bd2e31a8a130a11b6749279"
}

Last updated