Skip to content

Commit f608310

Browse files
committed
add example calculating expected pair addresses
1 parent 9d781ca commit f608310

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,37 @@ Ethereum Mainnet Address:
176176
```
177177
0x138a09B1822450a2d6cbbf59C72aecbb475b0f5f
178178
```
179+
180+
```
181+
const token0 = "0x6B175474E89094C44Da98b954EedeAC495271d0F";
182+
const token1 = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
183+
const factory = "0xee3E9E46E34a27dC755a63e2849C9913Ee1A06E2";
184+
185+
const initCode = "0x3d602d80600a3d3981f3363d3d373d3d3d363d737290367aa694703220516a35e68e3d339ee7d1935af43d82803e903d91602b57fd5bf3";
186+
187+
const initCodeHash = ethers.utils.solidityKeccak256(
188+
[
189+
'bytes'
190+
],
191+
[
192+
initCode
193+
]
194+
);
195+
196+
const salt = ethers.utils.solidityKeccak256(
197+
[
198+
'address',
199+
'address'
200+
],
201+
[
202+
token0,
203+
token1
204+
],
205+
);
206+
207+
const contractAddress = ethers.utils.getCreate2Address(
208+
factory,
209+
salt,
210+
initCodeHash,
211+
);
212+
```

0 commit comments

Comments
 (0)