Transaction

A transaction is an instruction issued by an account with a cryptographic signature. The account will initiate the transaction to update the state of the Ethernet network. The simplest transaction is a transfer of PSC from one account to another.

What is the transaction?

A PolySmartChain transaction is an action initiated by an externally held account, in other words, an account that is managed by a human rather than a smart contract. For example, if Bob sends Alice 1 PSC, Bob's account must be decreased by 1 PSC and Alice's account must be increased by 1 PSC. This action occurs during the transaction and changes the state.

Transactions that change the state of the EVM need to be broadcast to the entire network. Any node can broadcast a transaction request on the EVM; thereafter, the miner will execute the transaction and propagate the resulting state change to the rest of the network.

Transactions require a fee and must be mined to be valid. To make this overview simpler, we will call it Gas fees and mining.

The submitted transactions include the following information:

  • recipient – Receive address (if it is an externally held account, the transaction will transmit the value. If it is a contract account, the transaction will execute the contract code)

  • signature – The sender's identifier. This signature is generated when a transaction is signed by the sender's private key to ensure that the sender has authorized this transaction.

  • value – Amount of ETH transferred from sender to recipient (in WEI, a denomination of ETH)

  • data – Optional fields that can include any data

  • gasLimit – The maximum amount of Gas that can be consumed by a transaction. The Gas unit represents the calculation step

  • maxPriorityFeePerGas - Maximum amount of gas included as a miner's tip

  • maxFeePerGas - Maximum amount of gas willing to pay for the transaction(including baseFeePerGas and maxPriorityFeePerGas)

Gas is the amount of arithmetic power required by the miner to process the transaction. The user must pay a fee for this calculation. gasLimit and gasPrice determine the maximum transaction fee to be paid to the miner.

The transaction object looks like this:

//{ 
    from: "0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8", 
    to: "0xac03bb73b6a9e108530aff4df5077c2b3d481e5a", 
    gasLimit: "21000", 
    maxFeePerGas: "300" 
    maxPriorityFeePerGas: "10" 
    nonce: "0", 
    value: "10000000000",
}

However, the object of the transaction needs to be signed with the sender's private key. This proves that the transaction can only come from the sender and not from fraud.

The PolySmartChain client like GPSC will handle this signing process.

Example JSON-RPC call:

{
  "id": 2,
  "jsonrpc": "2.0",
  "method": "account_signTransaction",
  "params": [
    {
      "from": "0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db",
      "gas": "0x55555",
      "maxFeePerGas": "0x1234",
      "maxPriorityFeePerGas": "0x1234",
      "input": "0xabcd",
      "nonce": "0x0",
      "to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0",
      "value": "0x1234"
    }
  ]
}

Example response:

//{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "raw": "0xf88380018203339407a565b7ed7d7a678680a4c162885bedbb695fe080a44401a6e4000000000000000000000000000000000000000000000000000000000000001226a0223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20ea02aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663",
    "tx": {
      "nonce": "0x0",
      "maxFeePerGas": "0x1234",
      "maxPriorityFeePerGas": "0x1234",
      "gas": "0x55555",
      "to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0",
      "value": "0x1234",
      "input": "0xabcd",
      "v": "0x26",
      "r": "0x223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20e",
      "s": "0x2aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663",
      "hash": "0xeba2df809e7a612a0a0d444ccfa5c839624bdc00dd29e3340d46df3870f8a30e"
    }
  }
}
  • raw is the RLP (Recursive Length Prefix) encoded form of the signed transaction.

  • tx is the JSON form of the signed transaction.

If a signature hash is available, the transaction can be cryptographically proven to have come from the sender and submitted to the network.

Transaction Type

PolySmartChain has several different types of transactions:

  • Regular transactions: transactions from one wallet to another.

  • Contract Deployment Transactions: Transactions without "to" address, data field for contract code.

About Gas

As mentioned above, it costs Gas to execute the transaction. A simple transfer transaction costs 21,000 Gas.

Assuming that Bob wants to send 1 PSC to Alice for 190 gwei of baseFeePergas and 10 gwei of maxPriorityFeePerGas,then Bob needs to pay the following fees:

    (190 + 10) * 21000 = 4,200,000 gwei
    --or--
    0.0042 PSC

Bob's account will be reduced by 1.0042 PSC

Alice's account will be increased by +1.0 PSC

Deduct the base fee of 0.00399 PSC

Miners retain tips +0.000210 PSC

Any smart contract interaction also requires Gas.

Transaction Lifecycle

Once a transaction is submitted, the following happens:

  1. Once you send a transaction, the cryptography generates the transaction hash:0x97d99bc7729211111a21b12c933c949d4f31684f1d6954ff477d0477538ff017

  2. The transaction is then relayed to the network and included in a collection with a large number of other transactions.

  3. The miner must select your transaction and include it in a block in order to validate the transaction and consider it "successful".

    • If the network is busy and miners are unable to keep up, you may be able to wait at this stage.

  4. Your transaction will receive a "confirmation". The number of confirmations is the number of blocks created since the block containing your transaction. The larger this number is, the greater the certainty that the transaction will be processed and acknowledged by the network.

    • The most recent block may be reorganized, giving the impression that the transaction failed; however, the transaction may still be valid, but contained in another block.

    • The probability of reconfiguration decreases with each subsequent block mined, i.e., the more confirmations, the more immutable the transaction becomes.

Expanding Resources

Last updated