Transaction represents the format of communication between the clients and the smart contracts, securely and atomically, to execute an operation on their data. It also represents the unit of work and state change in the blockchain, and the main contents of the blocks. Transactions play an important role in any blockchain, by and large.
A transaction in the Züs Network consists of the following:
typeTransactionstruct {// Hash of the transaction, SHA256 of the fields of the transaction, concatenated// together and represented in HEX format. It's calculated automatically so no need to// be provided in the response body for the endpoints using this entity.//// required: false Hash string`json:"hash"`// Version of the transaction. Useful to differentiate between recent transactions and old ones.// When a change occur in the schema of the transactions and deployed to the mainnet, we need to // sure that the old transactions are still replayable. That's why we use versioning here// along with Hard Forking in the smartcontract code.//// required: true// default: "1.0" Version string`json:"version"`// ClientID of the client issuing the transaction//// required: true ClientID string`json:"client_id"`// Public key of the client issuing the transaction//// required: true PublicKey string`json:"public_key,omitempty"`// ToClientID - the client id of the recipient, the other party in the transaction. It can be a client id or the address of a smart contract//// required: true ToClientID string`json:"to_client_id,omitempty"`// ChainID - the chain id of the transaction//// required: true ChainID string`json:"chain_id,omitempty"`// TransactionData - the data associated with the transaction//// required: true TransactionData string`json:"transaction_data"`// Value - a numeric value associated with this transaction. Its role is determined by the smart contract function//// required: true Value currency.Coin`json:"transaction_value"`// Signature - Issuer signature of the transaction//// required: true Signature string`json:"signature"`// CreationDate - the time when the transaction was created//// required: true CreationDate common.Timestamp`json:"creation_date"`// Fee - the fee associated with the transaction//// required: true Fee currency.Coin`json:"transaction_fee"`// Nonce - the nonce associated with the transaction//// required: true Nonce int64`json:"transaction_nonce"`// TransactionType - the type of the transaction. // Possible values are:// - 0: TxnTypeSend - A transaction to send tokens to another account, state is maintained by account.// - 10: TxnTypeData - A transaction to just store a piece of data on the block chain.// - 1000: TxnTypeSmartContract - A smart contract transaction type.// required: true TransactionType int`json:"transaction_type"`// TransactionOutput - the output of the transaction//// required: true TransactionOutput string`json:"transaction_output,omitempty"`// OutputHash - the hash of the transaction output//// required: true OutputHash string`json:"txn_output_hash"`// Status - the status of the transaction.//// TxnSuccess = 1 - Indicates the transaction is successful in updating the state or smart contract// TxnError = 2 - Indicates a transaction has errors during execution// TxnFail = 3 - Indicates a transaction has failed to update the state or smart contract//// required: true Status int`json:"transaction_status"`}
Transaction Confirmation
After the transaction is selected in a block and the block is finalized, the sharder fires an event to add transaction confirmation, which is then added to the EventDB. For a client to make sure their transaction was successful, or to check the error in case of failure, they need to query the confirmation from the Sharder API.