Skip to main content
Version: Endpoint V1 Docs

Quick Guide to Lock Configuration

Fork and clone the repository

First fork this repo https://github.com/LayerZero-Labs/boilerplate

Bump to latest package

"@layerzerolabs/ua-utils": "latest",

Install dependencies

yarn

or

npm install

Enter seed phrase in your .env file

Enter seed phrase in .env file

Add Hardhat Config

Replace hardhat.config.ts with this hardhat config file.

This changes the hardhat network setups to our latest naming convention. If you wish to add more networks, please follow this name conventions.

import { HardhatUserConfig } from "hardhat/config"
import "@layerzerolabs/ua-utils"
import "hardhat-contract-sizer"
import "@nomiclabs/hardhat-waffle"
import "@nomiclabs/hardhat-etherscan"
import "@nomiclabs/hardhat-web3"
import "solidity-coverage"
import "hardhat-gas-reporter"
import "hardhat-deploy"
import "hardhat-deploy-ethers"

import "./tasks"
import * as dotenv from "dotenv"
dotenv.config({ path: __dirname+'/.env' })

function getMnemonic(networkName) {
if (networkName) {
const mnemonic = process.env['MNEMONIC_' + networkName.toUpperCase()]
if (mnemonic && mnemonic !== '') {
return mnemonic
}
}

const mnemonic = process.env.MNEMONIC
if (!mnemonic || mnemonic === '') {
return 'test test test test test test test test test test test junk'
}

return mnemonic
}

function accounts(chainKey) {
return { mnemonic: getMnemonic(chainKey) }
}
// you need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**
* @type
import('hardhat/config').HardhatUserConfig
*/
const config: HardhatUserConfig = {

solidity: {
compilers: [
{
version: "0.8.12",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
]
},
contractSizer: {
alphaSort: false,
runOnCompile: true,
disambiguatePaths: false,
},
namedAccounts: {
deployer: {
default: 0, // wallet address 0, of the mnemonic in .env
},
proxyOwner: {
default: 1,
},
},
networks: {
hardhat: {
accounts: accounts(),
},
"ethereum-mainnet": {
url: "https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161", // public infura endpoint
chainId: 1,
accounts: accounts(),
},
"bsc-mainnet": {
url: "https://1rpc.io/bnb",
chainId: 56,
accounts: accounts(),
},
"avalanche-mainnet": {
url: "https://api.avax.network/ext/bc/C/rpc",
chainId: 43114,
accounts: accounts(),
},
"arbitrum-mainnet": {
url: "https://arb1.arbitrum.io/rpc",
chainId: 42161,
accounts: accounts(),
},
// ... other network configurations ...
}
};
export default config

Generate config file

Generate the config file based on your current configuration

Networks: a comma separated list of each network and their respective UA address. In our example, it’s

fantom-testnet:0xFd7e266AF7CC7ef8645D6bF43C800b7f82ca1042
bsc-testnet:0xFd7e266AF7CC7ef8645D6bF43C800b7f82ca1042

Name: The name of your contract, used in a hardhat-deploy situation. you can just put “” to signal you’re not using hardhat-deploy, instead the address field would be present.

npx hardhat generateAppConfig --networks fantom-testnet:0xFd7e266AF7CC7ef8645D6bF43C800b7f82ca1042,bsc-testnet:0xFd7e266AF7CC7ef8645D6bF43C800b7f82ca1042 --name “”

The config json would then be generated at: constants/defaultConfig.json

Lock and view the setting

Lock the config with this command

npx hardhat setConfig --config-path "./constants/defaultConfig.json"

It would then show the progress of config setting.