Ethereum: how to extract the input address and the amount from Vin
When working with Ethereum operations to get data precision, it is very important to understand Vin (unique identification number). In this article, we will deepen the wine above to extract the address and amount of the aput.
Vin Structure
Vin is made up of several components:
- TXID: Operating ID
Vout ': output index
- N ‘: input number (optional)
I
: Input arrow (optional)
In your example, Vin is:
`Json
Vin: [
{
TXID: e3f0e88c224d342a0189c1b9d2fd488bda2f303dbe1e1dbaa5f51d9f4a53,
Vout: 1,
“N”: 1, // No input
“I”: 0 // Frech entrance (optional)
}
“
`
Input address and extraction of the amount
**
You can use the features of the Vin object to extract the input address and the Vin amount. Here's how to do this:
Javascript
Function Vindadata (Vin) {
Const inputindex = vin.vout; // Get output index (input arrow)
Const TXID = Vin.txid;
Const Sumpry = Vin.i? vin [i + 1] .mount: null; // get the first amount if they are not -1
return {
txid,
Vout: inputdex, // Remove the VIN arrow
amount
Input: vin.inputs.map ((input) => ({{{{{{{{{{{{{{{{{H AND {H HL AND AND IN AND IN AND IN AND IN AND IN AND IN AND IN AND IN AND AND AND AND AND AND IN H H havees ans eatore {{{{{{{{{{{{{HAC AND AND IN AND IN AND IN AND IN AND IN AND IN AND AND H H H H H have herself
TXID: input.txid,
Amount: input.mount,
N: input.n,
I: input.i,
})))
};
}
`
This function assumes that the "vin" object has a "i" property for the amount and, otherwise, returns Null. Vin Vout is used to obtain the input index.
Example of use
Suppose we have an operation with the following Vin:
Json
Vin: [
{
TXID: e3f0e88c224d342a0189c1b9d2fd488bda2f303dbe1e1dbaa5f51d9f4a53,
Vout: 1,
…
`
You can use the won function to extract the input address and the amount:
Javascript
Const Vin = {
TXID: “e3f0e88c224d342a0189c1b9d2fd488bda2f303dbe1e1dbbaa5f51d9f4a53”,
Vout: 1,
I: 0
};
Const Data = Winded (Vin);
Console.log (data); // output: {txid, vout, amount, input}
`
In this example, the output will be an object with the following qualities:
- TXID: Operating ID
- Vout ‘: Input arrow (1)
- “Amount”: the amount associated with the input
input ': objects containing:
+Txid
: ID input operation
+ `Sum ": input amount
+N ': input number
+I
: input arrow (if not -1)
This is a key example and it may be necessary to change the code to combine specific use. In addition, remember that this information is generally available only if the operation has been dug on Ethereum Mainnet or EIP-1559.
Leave a Reply