Factori.eth
์์ฃผ ์ฌ์ฉ๋๋ ์ปจํธ๋ํธ๋ค์ ์์ ์ฝ๋ ํฌ๊ธฐ๋ก ๋ฐฐํฌํ ์ ์์ผ๋ฉฐ, ๋ชจ๋ ๋ฐฐํฌ๋ ์ปจํธ๋ํธ๊ฐ ๊ณตํต๋ ์ฝ๋๋ฒ ์ด์ค๋ฅผ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ ์ ์ฒด ๋ธ๋ก์ฒด์ธ์ ํฌ๊ธฐ๋ฅผ ์ค์ด๋๋ฐ ๊ธฐ์ฌํฉ๋๋ค.
Deployed
Mainnet
- FactoryV1: 0x7906743465F43fe72Ced0986D62037920929dDC7
- Price: 0.01 ETH
- StandardERC20 key: 0xd84f5b1df9c4fd84edcba18d9eec1e0598f898a9d84025ffcd437e0b828fbbe5
- MerkleDistributor key: 0x27b7cec299fe3e6f5913fa9a95be3169fde20709807359cbdd0a76849bcbe97d
- VestingEscrow key: 0x8c5d5e4f2902234c981bd69bbfb6bf4cc9e4adbd704d340671dac44dcad3f0d8
Optimism
- FactoryV1: 0x677ef2B01493e235fE2271AFcd01d7e22975Ce5b
- Price: 0.001 ETH
- StandardERC20 key: 0x7f24bd37566ed112a5fd314170e33c8e40c7d269e0edb6191c4bdbb2abe55315
- L2StandardERC20 key: 0x2aa4348ea67f2b4fb341743986c38b48067fd815ea436e08a922b298733b5442
- MerkleDistributor key: 0xfe6535b0627e8568ef1eafa214039fd7c90acacd1dc934553a060683d6180097
- VestingEscrow key: 0x1e568a0b6523217334b8ae190af264b89824c9b23402a2ae782fb93bf6e99ad9
Goerli
- FactoryV1: 0x131bC833b5857A74466ce61b0A2EE4CFc2436002
- Price: 0.01 ETH
- StandardERC20 key: 0x39d750b6e6944bb4361c7379b5f0fa20f77b99adc94192761c67ffd0e3fb04e6
- MerkleDistributor key: 0x1df4fa81b7029485e75e8567a980cbb02ef58e65fda79384f7df2a0b6f5e9a3a
- VestingEscrow key: 0x4e2407a6af55c287bda11462e5e0810cdf2cf83c38200c3f0e9cccebe5e96106
Kovan
- FactoryV1: 0x43ccFa6D2E5cB209a4764Ad1DA46e5B5B32C644D
- Price: 0.01 ETH
- StandardERC20 key: 0x9826236a1bc4fc40f2cca879bc5ed99015ca0427eba794e5e6445427acd5055d
- MerkleDistributor key: 0x5d29e9fad9171dbbd99199b154f79a94c1583ceb907cb2ce6f89b701df69c647
- VestingEscrow key: 0xc4bfab919fc3beb03ab61980fca95cb2c49aa95c1762e6149adcd3b004266285
Optimism Testnet
- FactoryV1: 0xd5ac3B857177A0081e2BcF4CAd803e4FE2B5F366
- Price: 0.001 ETH
- StandardERC20 key: 0x6108e99ff7450dcaa72e5352300c431df06d6a29f7d4ef425ddd124775b2138c
- L2StandardERC20 key: 0x7086e604b2f6abf7cd6acd06ac7185589800477c125dccfec0ea104159c12786
- MerkleDistributor key: 0xe8d3e74813db60888defcb8ab86ac511fce6481052109d6e003ceb2388b6cce8
- VestingEscrow key: 0xd460dccff7ffce909ad9de70f40f3f2e48e0d4a48374991783a70fbcb5394df3
FactoryV1์ ํตํด์ ํ ํฐ์ ๋ฐฐํฌํ๊ธฐ ์ํด์๋ ๋ค์๊ณผ ๊ฐ์ ์์ ์ ํ์๋ก ํฉ๋๋ค.
const ABI = [
'function initialize(bytes calldata data)',
'function mintTo(address to, uint256 value)',
'function transferOwnership(address newOwner)',
];
const interfaces = new ethers.utils.Interface(ABI);
// ํ ํฐ ์ปจํธ๋ํธ์ ์ด๋ฆ
const tokenName = 'TESTToken';
// ํ ํฐ ์ปจํธ๋ํธ์ ์ฌ๋ณผ
const tokenSymbol = 'TT';
// ํ ํฐ์ ์์์ ์๋ฆฌ
const tokenDecimals = ethers.BigNumber.from('18');
// ์์์ ์๋ฆฌ๋ฅผ ํฌํจํ์ฌ ํ ํฐ์ ์ฒ์ ๋ฐฐํฌํ ์ซ์๋ ๋ค์์ด ๋ฉ๋๋ค. 100.000000000000000000
const initialToken = ethers.BigNumber.from('100000000000000000000');
// ํ ํฐ์ ๋ฐฐํฌํ๋ฉด์ ์ด๊ธฐํ ํ ๋ ํ์ํ ๋ฐ์ดํฐ๋ฅผ ์ง๋ ฌํ ํฉ๋๋ค.
const initdata = interfaces.encodeFunctionData('initialize', [
ethers.utils.defaultAbiCoder.encode(['string', 'string', 'uint8'], [tokenName, tokenSymbol, tokenDecimals]),
]);
// ํ ํฐ ์ปจํธ๋ํธ๋ฅผ ๋ฐฐํฌํ ๋ ํ ํฐ์ ์๋ นํ๋๋ก ํฉ๋๋ค.
// ํด๋น ์์
์ผ๋ก, ํ ํฐ ์๋์ด ๊ฒฐ์ ๋๊ณ ์ด ๊ณต๊ธ๋์ด ์
๋ฐ์ดํธ ๋ฉ๋๋ค.
const mintCallData = interfaces.encodeFunctionData('mintTo', [
'ํ ํฐ ์๋ น์ธ์ ์ด๋๋ฆฌ์ ์ฃผ์',
initialToken,
]);
// ๋ฐฐํฌ๋ ํ ํฐ ์ปจํธ๋ํธ์ ์์ ๊ถ ์ด์ (์ด ์์
์ด ์๋ค๋ฉด, ํ ํฐ ์ปจํธ๋ํธ์ ์์ ๊ถ์ factory๊ฐ ๊ฐ์ง๊ณ ์์ต๋๋ค)
// ํ ํฐ ์ปจํธ๋ํธ์ ์์ ๊ถ์ด ์๋ค๋ฉด ์ถํ์ ํ ํฐ์ ์์ฑํ๊ฑฐ๋ ์๊ฐํ ์ ์์ต๋๋ค.
const ownerCallData = interfaces.encodeFunctionData('transferOwnership', [
'ํ ํฐ ์ปจํธ๋ํธ์ ์์ ๊ถ์ ๊ฐ์ง ์ด๋๋ฆฌ์ ์ฃผ์',
]);
const Factory = await ethers.getContractAt(FACTORY_ABI, FACTORY_ADDRESS);
// factory์์ ํ ํฐ ์ปจํธ๋ํธ์ ํ
ํ๋ฆฟ ํค๋ฅผ ๋ฃ๊ณ , ์ด๊ธฐํ ๋ฐ์ดํฐ, ๊ทธ๋ฆฌ๊ณ ๊ฐ๊ฐ ํ์ํ ํธ์ถ์ ๋ฐฐ์ดํํ๋ก ๋ฃ์ด์ค๋๋ค.
await Factory['deploy(bool,bytes32,bytes,bytes[])'](
false,
TOKEN_KEY,
initdata,
[mintCallData, ownerCallData],
{ value: ethers.utils.parseEther('0.01') },
);
// tx๊ฐ ์๋ฃ๋๋ฉด ํ ํฐ ์ปจํธ๋ํธ๊ฐ ๋ฐฐํฌ๋์ด ํ ํฐ์ ๋ฐํํ๊ณ Factory๊ฐ ๊ฐ์ง๊ณ ์๋ ์ค๋์ญ์ ๋๊ธฐ๊ฒ ๋ฉ๋๋ค.