def generate_address_2(from_: Union[str, bytes], salt: Union[str, bytes], init_code: [str, bytes]) -> str:
    """
    Generates an address for a contract created using CREATE2.
    :param from_: The address which is creating this new address (need to be 20 bytes)
    :param salt: A salt (32 bytes)
    :param init_code: A init code of the contract being created
    :return: Address of the new contract
    """

    from_ = HexBytes(from_)
    salt = HexBytes(salt)
    init_code = HexBytes(init_code)

    assert len(from_) == 20, "Address %s is not valid. Must be 20 bytes" % from_
    assert len(salt) == 32, "Salt %s is not valid. Must be 32 bytes" % salt
    assert len(init_code) > 0, "Init code %s is not valid" % init_code

    init_code_hash = Web3.sha3(init_code)
    contract_address = Web3.sha3(HexBytes('ff') + from_ + salt + init_code_hash)
    return Web3.toChecksumAddress(contract_address[12:])
def generate_address_2(from_: Union[str, bytes], salt: Union[str, bytes], init_code: [str, bytes]) -> str:
    """
    Generates an address for a contract created using CREATE2.
    :param from_: The address which is creating this new address (need to be 20 bytes)
    :param salt: A salt (32 bytes)
    :param init_code: A init code of the contract being created
    :return: Address of the new contract
    """

    from_ = HexBytes(from_)
    salt = HexBytes(salt)
    init_code = HexBytes(init_code)

    assert len(from_) == 20, "Address %s is not valid. Must be 20 bytes" % from_
    assert len(salt) == 32, "Salt %s is not valid. Must be 32 bytes" % salt
    assert len(init_code) > 0, "Init code %s is not valid" % init_code

    init_code_hash = Web3.sha3(init_code)
    contract_address = Web3.sha3(HexBytes('ff') + from_ + salt + init_code_hash)
    return Web3.toChecksumAddress(contract_address[12:])
def generate_address_2 ( from_ : Union [ str , bytes ] , salt : Union [ str , bytes ] , init_code : [ str , bytes ] ) -> str : from_ = HexBytes ( from_ ) salt = HexBytes ( salt ) init_code = HexBytes ( init_code ) assert len ( from_ ) == 20 , "Address %s is not valid. Must be 20 bytes" % from_ assert len ( salt ) == 32 , "Salt %s is not valid. Must be 32 bytes" % salt assert len ( init_code ) > 0 , "Init code %s is not valid" % init_code init_code_hash = Web3 . sha3 ( init_code ) contract_address = Web3 . sha3 ( HexBytes ( 'ff' ) + from_ + salt + init_code_hash ) return Web3 . toChecksumAddress ( contract_address [ 12 : ] )
Generates an address for a contract created using CREATE2.
    :param from_: The address which is creating this new address (need to be 20 bytes)
    :param salt: A salt (32 bytes)
    :param init_code: A init code of the contract being created
    :return: Address of the new contract
Generates an address for a contract created using CREATE2 . : param from_ : The address which is creating this new address ( need to be 20 bytes ) : param salt : A salt ( 32 bytes ) : param init_code : A init code of the contract being created : return : Address of the new contract