# Tx

# tx_sendRawTx

Send a raw transaction block

  • Parameters: Object: RawTxBlock

    Mandatory:

    • blockType: byte Block type
    • height: string Height
    • hash: Hash Transaction hash
    • prevHash: Hash The hash of previous block in the account chain. Fill 0 if there is no previous block
    • accountAddress: Address Account address
    • publicKey: []byte Account's public key
    • signature: []byte Signature

    Optional: below fields should be filled upon sending transaction through pow, otherwise can be ignored or filled with null

    • difficulty: *string PoW difficulty
    • nonce: []byte Nonce

    Optional: below fields should be filled depending on the transaction type (send or receive)

    • fromBlockHash: Hash The hash of corresponding request transaction. Required for response transaction
    • toAddress: Address The account address to send the transaction to. Required for request transaction
    • tokenId: TokenTypeId The token ID in which the transaction is settled. Required for request transaction
    • amount: *string Transaction amount. Required for request transaction
    • fee: *string Transaction fee. Fill "0" or null for all transactions
    • data: []byte Additional data the transaction carries. This field can be specified in request transaction for user account as additional comment or formalized data used to call a contract. Ignore or fill with null if not used.
  • Returns: Object: AccountBlock

    • blockType: byte
    • height: string
    • hash: Hash
    • prevHash: Hash
    • accountAddress: Address
    • publicKey: []byte
    • signature: []byte
    • fromAddress: Address
    • toAddress: Address
    • fromBlockHash: Hash
    • tokenId: TokenTypeId
    • amount: *string
    • fee: *string
    • data: []byte
    • difficulty: *string
    • nonce: []byte
    • quota: *string The quota consumed by the transaction, excluding temporary quota obtained through PoW
    • quotaUsed: *string The quota consumed by the transaction
    • utUsed: *string The quota consumed by the transaction in Unit Transactions (rounded to 4 decimals)
    • logHash: *types.Hash The hash of LogList generated by smart contract
    • sendBlockList: []*RawTxBlock A list of request transactions sent from within the block. RS block only
    • tokenInfo: *RpcTokenInfo The token information in which the transaction is settled
    • confirmedTimes: *string The confirmation number of the transaction
    • confirmedHash: *Hash The hash of snapshot block in which the transaction was snapshotted
    • timestamp: int64 The timestamp(seconds) in which the transaction was snapshotted
    • receiveBlockHeight: *string The height of the corresponding response transaction. Request transaction only
    • receiveBlockHash: *Hash The hash of the corresponding response transaction. Request transaction only
  • Example:

# tx_calcPoWDifficulty

Obtain current PoW difficulty for sending a transaction via sendRawTx.

This method calculates the required quota based on given transaction parameters, and then determines whether the account has enough quota from staking. Difficulty is only calculated if the account does not have sufficient quota. If error is returned, it could be because too many characters in data field, or the current transaction cannot obtain quota by calculating PoW. For example, during the same snapshot period, if previous transaction in the account chain has obtained quota through calculating PoW, calling this method for next transaction will throw an error.

  • Parameters:

    • selfAddr: Address Account address
    • prevHash: Hash The hash of previous block in the account chain. Fill 0 if there is no previous block
    • blockType: byte Transaction type
    • toAddr: Address The account address to send the transaction to. Required for request transaction. Fill null for response.
    • data: []byte Additional data the transaction carries. Fill null for response transaction.
    • usePledgeQuota: bool Whether quota from staking is used first
  • Returns: Object

    • difficulty: big.Int Current PoW difficulty. Empty string means calculating PoW is not necessary
    • quotaRequired: uint64 Quota that will be consumed by the transaction
    • utRequired: uint64 Quota that will be consumed by the transaction in Unit Transactions (rounded to 4 decimals)
    • isCongestion: bool An indicator to show if the network is jammed at the time being. If the value is true, the quota consumed by the transaction will increase.
  • Example:

# tx_calcQuotaRequired

Calculate the quota required for sending the transaction

  • Parameters:

    • selfAddr: Address Account address
    • blockType: byte Transaction type
    • toAddr: Address The account address to send the transaction to. Required for request transaction. Fill null for response.
    • data: []byte Additional data the transaction carries. Fill null for response transaction.
  • Returns: Object

    • quotaRequired: uint64 Quota that will be consumed by the transaction
    • utRequired: uint64 Quota that will be consumed by the transaction in Unit Transactions (rounded to 4 decimals)
  • Example: