hg0088线上

hg0088线上transactions are cryptographically signed instructions from accounts. an account will initiate a transaction to update the state of the ethereum network. the simplest transaction is transferring eth from one account to another.

Prerequisites

To help you better understand this page, we recommend you first read Accounts and our introduction to Ethereum.

What's a transaction?

hg0088线上an ethereum transaction refers to an action initiated by an externally-owned account, in other words an account managed by a human, not a contract. for example, if bob sends alice 1 eth, bob's account must be debited and alice's must be credited. this state-changing action takes place within a transaction.

transactions, which change the state of the evm, need to be broadcast to the whole network. any node can broadcast a request for a transaction to be executed on the evm; after this happens, a 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 become valid. to make this overview simpler we'll cover gas fees and mining elsewhere.

a submitted transaction includes the following information:

Gas is a reference to the computation required to process the transaction by a miner. Users have to pay a fee for this computation. The gasLimit and gasPrice determine the maximum transaction fee paid to the miner. More on Gas.

the transaction object will look a little like this:

1{
2 from: "0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8",
3 to: "0xac03bb73b6a9e108530aff4df5077c2b3d481e5a",
4 gasLimit: "21000",
5 gasPrice: "200",
6 nonce: "0",
7 value: "10000000000",
8}
9
📋 Copy

but a transaction object needs to be signed using the sender's private key. this proves that the transaction could only have come from the sender and was not sent fraudulently.

an ethereum client like geth will handle this signing process.

hg0088线上example call:

1{
2 "id": 2,
3 "jsonrpc": "2.0",
4 "method": "account_signTransaction",
5 "params": [
6 {
7 "from": "0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db",
8 "gas": "0x55555",
9 "gasPrice": "0x1234",
10 "input": "0xabcd",
11 "nonce": "0x0",
12 "to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0",
13 "value": "0x1234"
14 }
15 ]
16}
17
📋 Copy

hg0088线上example response:

1{
2 "jsonrpc": "2.0",
3 "id": 2,
4 "result": {
5 "raw": "0xf88380018203339407a565b7ed7d7a678680a4c162885bedbb695fe080a44401a6e4000000000000000000000000000000000000000000000000000000000000001226a0223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20ea02aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663",
6 "tx": {
7 "nonce": "0x0",
8 "gasPrice": "0x1234",
9 "gas": "0x55555",
10 "to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0",
11 "value": "0x1234",
12 "input": "0xabcd",
13 "v": "0x26",
14 "r": "0x223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20e",
15 "s": "0x2aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663",
16 "hash": "0xeba2df809e7a612a0a0d444ccfa5c839624bdc00dd29e3340d46df3870f8a30e"
17 }
18 }
19}
20
📋 Copy

with the signature hash, the transaction can be cryptographically proven that it came from the sender and submitted to the network.

On gas

As mentioned, transactions cost gas to execute. Simple transfer transactions require 21000 units of Gas.

So for Bob to send Alice 1ETH at a gasPricehg0088线上 of 200 Gwei, he'll need to pay the following fee:

1200*21000 = 4,200,000 GWEI
2--or--
30.000000004 ETH
4

Bob's account will be debited -1.000000004 ETH

Alice's account will be credited +1.0 ETH

The miner processing the transaction will get +0.000000004 ETH

Transaction lifecycle

hg0088线上once the transaction has been submitted the following happens:

  1. Once you send a transaction, cryptography generates a transaction hash: 0x97d99bc7729211111a21b12c933c949d4f31684f1d6954ff477d0477538ff017
  2. The transaction is then broadcast to the network and included in a pool with lots of other transactions.
  3. A miner must pick your transaction and include it in a block in order to verify the transaction and consider it "successful".
    • You may end up waiting at this stage if the network is busy and miners aren't able to keep up. Miners will always prioritise transactions with higher GASPRICE because they get to keep the fees.
  4. Your transaction will also get a block confirmation number. This is the number of blocks created since the block that your transaction was included in. The higher the number, the greater the certainty that the transaction was processed and recognised by the network. This is because sometimes the block your transaction was included in may not have made it into the chain.
    • The larger the block confirmation number the more immutable the transaction is. So for higher value transactions, more block confirmations may be desired.

Further reading

Know of a community resource that helped you? Edit this page and add it!

Back to top ↑
  • On this page
  • Prerequisites
  • What's a transaction?
  • Transaction lifecycle
  • Further reading
  • Related topics