Easier Send Transaction

Send transaction easily with this example:

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

Name
Type
Description

sender

string or hexadecimal

Wallet address

sender_pk

string or hexadecimal

Sender's private key

To

string or hexadecimal

Receiver's wallet address

payload

string or hexadecimal

String in hexadecimal format

blockchain

string or hexadecimal

Blockchain address excluding the "0x" hexadecimal identifier

type

string

One of the types listed before

Example

from circular_protocol_api import CircularProtocolAPI
from circular_protocol_api import helper

timestamp = helper.getFormattedTimestamp()
blockchain = helper.hexFix(blockchain)
nonce = int(self.getWalletNonce(blockchain, sender)["Response"]["Nonce"]) + 1
payload = helper.hexFix(json.dumps(payload).encode().hex())
sender = helper.hexFix(sender)
sender_pk = helper.hexFix(sender_pk)
to = helper.hexFix(to)
ID = str(blockchain + sender + to + payload + str(nonce) + timestamp)
hashID = helper.sha256(ID)
signature = helper.signMessage(hashID, sender_pk)

data = {
    'ID': hashID,
    'From': sender,
    'To': to,
    'Timestamp': timestamp,
    'Type': type,
    'Payload': payload,
    'Nonce': f"{nonce}",
    'Signature': signature,
    'Blockchain': blockchain,
    'Version': self.__version__
}

return helper.sendRequest(data, nag._SEND_TRANSACTION, self.__NAG_URL__)

Result

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

Last updated