BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/Wednesday UI/create2

create2

wednesday-ui/create2
FreeUtility

Wednesday UI publishes no description for this item.

Install it

npx shadcn@latest add https://ui.ednesdayw.com/r/create2.json

Source

src/registry/lib/create2.tsui.ednesdayw.com/r/create2.json · first 6 KB
1import { createHash } from "crypto";
2import bs58 from "bs58";
3import { keccak256 } from "js-sha3";
4import { isEVMAddress, isTronAddress } from "./wallet-address";
5
6// ============ Types ============
7interface Create2PredictAddressParams {
8 implementation: string;
9 deployer: string;
10 salt: string;
11}
12
13// ============ Constants ============
14// EIP-1167 Minimal Proxy Bytecode
15const MINIMAL_PROXY = {
16 PREFIX: "3d602d80600a3d3981f3363d3d373d3d3d363d73",
17 EVM_SUFFIX: "5af43d82803e903d91602b57fd5bf3ff",
18 TRON_SUFFIX: "5af43d82803e903d91602b57fd5bf341",
19} as const;
20
21// Bytecode Processing
22const BYTECODE_CONFIG = {
23 FIRST_PART_END: 110,
24 SECOND_PART_END: 280,
25 ADDRESS_SIZE: 40,
26} as const;
27
28// ============ Main Functions ============
29
30/**
31 * Predicts the deterministic address for a contract using CREATE2
32 */
33export function create2(
34 data: Create2PredictAddressParams & { network?: "evm" | "tron" },
35) {
36 const { implementation, deployer, salt, network = "evm" } = data;
37 if (network === "evm") {
38 return predictDeterministicEVMAddress({ implementation, deployer, salt });
39 }
40 return predictDeterministicTronAddress({ implementation, deployer, salt });
41}
42
43/**
44 * Predicts the deterministic address for an EVM contract using CREATE2
45 */
46export function predictDeterministicEVMAddress({
47 implementation,
48 deployer,
49 salt,
50}: Create2PredictAddressParams): string {
51 // Validate inputs
52 validateEVMAddress(implementation, "implementation");
53 validateEVMAddress(deployer, "deployer");
54 validateSalt(salt);
55
56 // Prepare parameters
57 const saltHex = stringToHex(salt, 32);
58 const cleanImplementation = removeHexPrefix(implementation);
59 const cleanDeployer = removeHexPrefix(deployer);
60
61 // Build bytecode
62 const bytecode = buildBytecode(
63 cleanImplementation,
64 cleanDeployer,
65 saltHex,
66 MINIMAL_PROXY.EVM_SUFFIX,
67 );
68
69 // Calculate address
70 const addressHex = calculateAddressFromBytecode(bytecode);
71 return toChecksumAddress(`0x${addressHex}`);
72}
73
74/**
75 * Predicts the deterministic address for a TRON contract using CREATE2
76 */
77export function predictDeterministicTronAddress({
78 implementation,
79 deployer,
80 salt,
81}: Create2PredictAddressParams): string {
82 // Validate inputs
83 validateTronAddress(implementation, "implementation");
84 validateTronAddress(deployer, "deployer");
85 validateSalt(salt);
86
87 // Prepare parameters
88 const saltHex = stringToHex(salt, 32);
89 const cleanImplementation = tronAddressToHex(implementation);
90// … truncated

What it pulls in

npm packages

  • js-sha3

Other registry items

  • https://ui.ednesdayw.com/r/wallet-address.json

Files it writes

  • src/registry/lib/create2.ts

Facts

Registry
Wednesday UI
Type
registry:lib
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-01
Last confirmed
yesterday

Go to the source

ui.ednesdayw.com xxxijustwei/ednesdayW on GitHub Raw registry item This item as JSON

More from Wednesday UI

All 99 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
colorscolorsWednesday UIUtilitiesFreeno deps
paginatepaginateWednesday UIUtilitiesFreeno deps
utilsutilsWednesday UIUtilitiesFree2 deps
wallet-addresswallet-addressWednesday UIUtilitiesFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex