Drep transactions are transfers of drep that exist within blocks. There are many types of transactions, which are ordinary transaction, creating smart contract transaction, calling smart contract transaction, and sending alias transaction. Each transaction is tailored to one specific occasion, and the user selects the transaction type according to its own need.
- Ordinary transaction Send DREP Token from one address to another address, realizing assets transfer.。
- Creating smart contract transaction Put contracts written in solidity language on Chain to facilitate the decentralized execution of the contract.
- Executing smart contract transaction A new contract address is generated after the creation of smart contract; The user sends a transaction based on its own right, and can also execute the smart contract.
- Sending alias transaction It is difficult to remember DREP address type, so the user can set an alias for its own account address. Replacing alias with address is much easier for memory and usage.
At the protocol level, all transactions share the same basic transaction format; The type of transaction is determined by the type field in the transaction. The section below describes this basic transaction format.
Below are the top-level fields of any transaction data.
|Version||Transaction version. This number is used to signify how the transaction should be interpreted.||8 bytes|
|Nonce||Record the number of transactions sent from one account address||1- 8 bytes|
|Type||Transaction type||8 bytes|
|To||The recipient of the transfer, if it is Nil, it means creating a smart contract||20 bytes|
|ChainId||Identify different types of network IDs||4 bytes|
|Amount||The amount of the transfer; if it is 0, it means calling the smart contract.||128 bytes|
|GasPrice||The gas fee set for the current transaction||128 bytes|
|GasLimit||Set the maximum amount of gas for the current transaction. During the transaction, if the gas amount exceeds this setting, the execution of transaction will fail.||128 bytes|
|Timestamp||The system timestamp of the transaction|
|Data||The data carried by the transaction, contract information is stored here when publish or call smart contract; it can be a storage space for other transactions.||varary|
Below are the top-level fields of any transaction other.
|Sig||Signature information for the transaction||varary|
|txHash||The transaction hash, store this value to save computing time||20bytes|
|signMessage||Store serialized data in transaction to save computing time||varary|
|message||Store serialized transaction data to save computing time||varary|
|from||Store the source send address to save computing time||10 bytes|
The serialization and the hash calculation of transaction require a lot of CPU resources. Therefore, DREP will serialize the transaction and record the data after hash calculation in database, and it can be directly read when needed. The transaction uses drepbinary to serialize it directly to obtain a serialized value, and uses sha3.Keccak256 to get a hash value.
Below we examine example from the Drep mainnet.
Raw Transaction (Hex)¶
Here is the raw hex data for the example transaction.