Solidity-028AddressValidations

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract AddressValidations {

    // Function to extract an address from a given hash and signature components (v, r, s)

    function ExtractAddress(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public returns(address) {

        // Prefix string as per Ethereum message signing standards

        bytes memory prefix = "\x19Ethereum Signed Message:\n32";

        // Compute the prefixed hash which includes the standard prefix

        bytes32 prefixedHash = keccak256(abi.encodePacked(prefix, hash));

        // Recover and return the address from the signature using ecrecover

        return ecrecover(prefixedHash, v, r, s);

    }

    // Alternative version of the function to extract an address from a hash and a signature bytes array

    function ExtractAddressAn

你可能感兴趣的:(Solidity,区块链,金融,智能合约,分布式账本,信任链)