function getCreate2Address(
   _from, 
   _salt, 
   _initCodeHash): string

Returns the address that would result from a CREATE2 operation with the given from, salt and initCodeHash.

To compute the initCodeHash from a contract’s init code, use the keccak256 function.

For a quick overview and example of CREATE2, see Wisps: The Magical World of Create2.

Parameters

ParameterTypeDescription
_fromstringThe address of the sender.
_saltBytesLikeThe salt value.
_initCodeHashBytesLikeThe hash of the init code.

Returns

string

The computed address.

Example

// The address of the contract
from = '0x8ba1f109551bD432803012645Ac136ddd64DBA72';

// The salt
salt = id('HelloWorld');

// The hash of the initCode
initCode = '0x6394198df16000526103ff60206004601c335afa6040516060f3';
initCodeHash = keccak256(initCode);

getCreate2Address(from, salt, initCodeHash);

Throws

If the salt is not exactly 32 bytes long.

Throws

If the initCodeHash is not exactly 32 bytes long.

Source

address/contract-address.ts:79