Skip to main content

Config

config.json

It can change the initial environment settings by setting the config file separately in the root path. However, the config file is not required and if it does not exist or some entries are not present, it will act as a default setting built into the code. Therefore, if separate environment settings are not required, they can be omitted.

~project_root/diamond.config.ts
export const config = {
deployer: {
address: process.env.DEPLOYER,
privateKey: process.env.PRIVATE_KEY,
},
artifact: {
diamonds: ["MyDiamond", "contracts/myapp/diamond2/MyDiamond.sol:MyDiamond"],
abi: {
include: ["facet", "facets", "shared"],
exclude: ["Data", "Facet"],
path: "artifacts/.diamonds",
file: "diamond",
},
},
loupe: {
path: "artifacts/.diamonds",
file: "facet",
},
};

export default config;

None of the following fields in the config file are required. values could be added and changed if only needed.

deployer

address : string

The owner address is an initial value that will be used as the 'owner' property of diamond args, at the time of deploying the diamond factory. If no value is provided for the field, the default address provided by Hardhat will be used.

artifacts

diamonds : string[]

Define here, which diamond files required generating an integrated abi of diamonds. If a diamond contract is used with a duplicate name, it must be identified by providing an artifact name that includes the full path to the diamond.

diamonds: [
'MyDiamond',
'contracts/myapp/diamond2/MyDiamond.sol:MyDiamond'
],

abi

include

include : string[] or ['facet', 'facets', 'shared'] as default.

String words defined in include properties are used to search artifacts of facet contracts. If the 'MyDiamond' was defined as the name of the diamond in the above artifacts.diamond, will find facets that include the words in their path from paths that include the diamond name.

[
'contracts/myapp/MyDiamond.sol:MyDiamond',
+ 'contracts/myapp/facets/Mint.sol:Mint',
+ 'contracts/myapp/facets/Burn.sol:Burn',
+ 'contracts/myapp/facets/Approval.sol:Approval',
+ 'contracts/myapp/facets/Transfer.sol:Transfer',
]

If there are some artifacts not include the filter words among this filtered result of artifacts, those artifacts as a starting point, and other facets will be excluded under those.

[
'contracts/myapp/MyDiamond.sol:MyDiamond',
+ 'contracts/myapp/facets/Mint.sol:Mint',
+ 'contracts/myapp/facets/Burn.sol:Burn',
+ 'contracts/myapp/facets/Approval.sol:Approval',
+ 'contracts/myapp/facets/Transfer.sol:Transfer',
'contracts/myapp/vault/MyVaultDiamond.sol:MyVaultDiamond',
# 'contracts/myapp/vault/facets/Deposit.sol:Deposit',
# 'contracts/myapp/vault/facets/Withdraw.sol:Withdraw',
# 'contracts/myapp/vault/facets/Lockup.sol:Lockup'
]

If there is no artifact not included in the filter among this result of artifacts, all of these artifacts will be combined to the name of the diamond.

[
'contracts/myapp/MyDiamond.sol:MyDiamond',
- 'contracts/myapp/IMyDiamond:MyDiamond',
- 'contracts/myapp/Data.sol:Data',
+ 'contracts/myapp/facets/Mint.sol:Mint',
+ 'contracts/myapp/facets/Burn.sol:Burn',
+ 'contracts/myapp/facets/Approval.sol:Approval',
+ 'contracts/myapp/facets/Transfer.sol:Transfer',
! 'contracts/myapp/vault/facets/Deposit.sol:Deposit',
! 'contracts/myapp/vault/facets/Withdraw.sol:Withdraw',
! 'contracts/myapp/vault/facets/Lockup.sol:Lockup'
]

The words defined in the exclude property will be used for excluding some artifacts in the final result.

In the path of the diamond, If there are some other contract files that those not the diamond, have to be defined into the exclude filter. If not, it will not work correctly because of cannot recognize what is the diamond in those files.

[
'contracts/myapp/MyDiamond.sol:MyDiamond',
- 'contracts/myapp/Data.sol:Data',
+ 'contracts/myapp/facets/Mint.sol:Mint',
+ 'contracts/myapp/facets/Burn.sol:Burn',
+ 'contracts/myapp/facets/Approval.sol:Approval',
+ 'contracts/myapp/facets/Transfer.sol:Transfer',
]
path

path: string or artifacts/.diamond as default.

Defines the path that will generate artifacts incorporating abi for a specific diamond. The default is to create a diamond artifact in the '.diamond' folder under the 'artifacts' folder in the project root path.

file

file: string or .diamond as default.

Add a suffix to the name of the file to identify the diamond artifact file that integrates abi. The default is 'diamond'. (Example: MyApp.diamond.sol)

loupe

After deployment a diamond, the information on the facets registered in the diamond and its selectors is exported to a file.

path

path: string or artifacts/.diamond as default.

By default, it uses the same path as the diamond artifacts path. (artifacts/.diamond)

file

file: string or .diamond as default.

After deploying the Diamond contract, add a suffix to the file name to identify the file from which you extracted the facet information registered in Diamond. The default is 'facet'. (e.g. MyApp.facets.sol)