Athereum Scriptpubkey Address: How to Fold them with transaction segwit
As a delaymaker or analytics of data, working with the transaction of Ethereum, you, verifiable, by the concentrations of the adsresis scriptpubkey (SPTK). These addresses are used in the transaction of Ethereum and generated the decrease of matematic heads, the existence as “evidence of work” (Pow), use their own unique cryptographic.
However, not all SPTK can be easily extended from unproven data about transaction with standard methods. This is connected with the fact that the transaction segwit, presented in 2017, use the separation walls (fastened as “scriptsig”) for the chronic methodological and parameters for each transaction. The section of the Scriptsig coordinates such information, as a public address, the scheme of signatures and other Polish fields.
To predefoot this, we dissatisfied with some translation techniques for the existence of the SPTK transaction transaction, using the ethereum wall tongue.
Why can’t we just use Scriptpubkey?
In the past, it was possible to fallen apart SPTK unwavering from the unproven data on the transaction of the analysis of the scriptsig. However, the transaction of the transaction segwit add -on -the -ilers, the divisions in this section, is not more accessed for standard instruments and library ethereum.
Method 1: Using library eth-sig
Odin from the predatory pre-adjunction of this scoring-scraping of the soda named “Eth-SIG”. This library imposes API for the existence of the segwit transaction transaction. Here’s the primer that you can use it:
`Javascript
Const {ethsig} = require ('eth-sig');
// Download data transaction
const txdata = ...;
// Beyond the section of Scriptsig
Const Scriptsig = txdata.scriptsig;
// Analyzide the walls, using the libraryeth-sig
Const siginfo = ethsig.parse (Scriptsig);
// Beyond the address SPTK from the signature scheme
Const Spkaddress = siginfo.pkaddress;
Console.log (SPKAddress);
Method 2: Using the Polish Wall
The second underweight is concluded in the realization of the polished wall, which is extended by the transaction of the SPTK from the transaction segwit. This walls should be compared and unfold in the quality of the counteract on the wickedness, which may be used in the founding code.
Here’s the primer that you can realy the Polish wall:
`
PRAGMA SOLIDY ^0.6,0;
CONTACT SPTKEXTOR {
GETSPKADDRESS (BYTES MEMORMY TXDATA) Function)
// Download data transaction
bytes32 txhash = txdata.read (0);
// Analyzide the hash transaction as signs ethereum
Address SPKAddress;
bytes4 [] Memory RSP = New Bytes4 [64];
uint8 [] memory sigs = txhash.read (1);
for (uint256 I = 2; I <65; I ++) {
RSP [i] = bytes4 (sigs [i] .byte ());
}
// Beyond the address SPTK from the signature scheme
SPKAddress = Keccak256 (RSP);
Return SPKAddress;
}
}
`
Method 3: Using the Thront Library and Web3.js
Again, you can also use the soder library, such as Web3.js
, to keep the SPTK from the transaction segwit. This technique sets more settings and configurations, but provides access to the unusual libraries and API.
Here’s the primer that you could use web3.js
with libraryeth-sig ':
Javascript
Const Web3 = Require ('Web3');
Const {ethsig} = require ('eth-sig');
// Download Web3 copy
const web3instance = new web3.web3 (new web3.providers.httpprovider ('
// Download data transaction
const txdata = ...;
// Beyond the section of Scriptsig
Const Scriptsig = txdata.scriptsig;
// Analyzide the walls, using the libraryeth-sig`
Const siginfo = ethsig.