Skip to content

Instantly share code, notes, and snippets.

@lsbyerley
Last active February 14, 2022 16:13
Show Gist options
  • Save lsbyerley/9981918eafee1dbdb3f198dc0b304147 to your computer and use it in GitHub Desktop.
Save lsbyerley/9981918eafee1dbdb3f198dc0b304147 to your computer and use it in GitHub Desktop.
const hre = require('hardhat');
const zksync = require('zksync');
const GOVERNANCE_RINKEBY = '0xC8568F373484Cd51FDc1FE3675E46D8C0dc7D246';
const NFT_CONTRACT = '0x6B1b6167B423505CCa1265Bf9E64AC6bd374Ea9e'; // deployed contract address
async function main() {
const NFTContract = await hre.ethers.getContractFactory('NFTContract');
const ethersProvider = new hre.ethers.getDefaultProvider('rinkeby');
const ethWallet = new hre.ethers.Wallet(process.env.WALLET_KEY, ethersProvider);
const zkSyncProvider = await zksync.getDefaultProvider('rinkeby');
const syncWallet = await zksync.Wallet.fromEthSigner(ethWallet, zkSyncProvider);
// address will be used as the creator
const address = ethWallet.address;
// const factory = await _getFactoryContract(ethWallet);
const factory = await NFTContract.attach(NFT_CONTRACT);
const _accountId = await syncWallet.getAccountId();
const _accountIdHex = hre.ethers.utils.hexValue(_accountId);
const accountId = `000${_accountIdHex.split('0x')[1]}`;
const creatorAddress = address.split('0x')[1].toLowerCase();
const factoryAddress = factory.address.split('0x')[1].toLowerCase();
const msg = `\nCreator's account ID in zkSync: ${accountId}\nCreator: ${creatorAddress}\nFactory: ${factoryAddress}`;
const signature = await ethWallet.signMessage(msg);
console.time('REGISTER_FACTORY');
const txn = await factory.registerFactory(GOVERNANCE_RINKEBY, _accountId, address, signature);
await txn.wait();
console.timeEnd('REGISTER_FACTORY');
console.log('LOG: factory registry complete!', txn);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment