Ethereum: Deploying Multiple Contracts at the same address using hardhat

Stir in multiple contracts at the same address using hardhat

Ethereum: Deploying Multiple Contracts at the same address using hardhat

In the recent versions of the hardhat, there is a new way to distribute multiple contracts at the same address. This feature allows you to create a contract that can be arranged with other arguments or variables.

Solution

To arrange two contracts A and B at the same address using the hardhat 4.X you can use -network 'option and submit numerous contract addresses as arguments.

Here's an example:

Json

// contract

Const Treaty = Artefacts.require (“Treaty”);

Const Treaty = Artefacts.require (“Overbin”);

Module.exports Noskecontracts () {) {) {)

Return ETERS.PROVIDERS.Deployer.at (“0x …”). Then ((provider) => {

Const [contracts, persortbaddress] = [“0x …”, “0x …”];

// Introducing a contract A and B at the same address

Expect the contract.new ({from: Provider, Data: [], nonce: 0});

Waiting for Contravab.new ({from: Provider, Data: [], nonce: 0});

// Use distributed contracts in your next contract

Const Treaty = contract.at (contract);

Const Treaty = Objeb.at (Contracting);

return [contract, contract];

});

Iche

`

Json

// script/hardhat.js

Const {implementation} = demand (“hardhat”);

Module.exports Noskecontracts () {) {) {)

Return a new promise ((solution) => {

to schedule ([{{{{{{{{{{{{{{{

Contract: “Contracts/Treaty.Json”,

From: “0x …”,

Gasprice: 10000,

Gaslimit: 2000000,

Nonce: 0,

}], (Err, accounts) => {

If (Err) {

Console.error (Err);

return;

Iche

// Get arranged contracts

Const [contractDadress, persortbaddress] = Account.map ((account) =>

Contract.at (Contracting)

);

// Use distributed contracts in your next contract

for resolving ([contracts, contractness]);

});

});

Iche

`

In this example, we define two contracts and contracts of "contract". Then we will arrange both contracts to the same address using the "DeployContracts" function. The "implementation" hook allows us to submit a series of contracts as arguments.

"DeplayContracts" will restore the promise that is processed with a cough agreement of the addressed addresses. In this case, we use the method ofcards to draw addresses of each contract from the account.

Example of using the case

In the next hard script you can use arranged contracts in function or variables.

`Javascript

// script/hardhat.js

Const {DeplayContracts} = demand (“.

Async function main () {)

Const [contracts, persortbaddress] = expect DeployContracts ();

// Use distributed contracts in your next contract

Const Treaty = contract.at (contract);

Const Treaty = Objeb.at (Contracting);

// do something with contracts …

Iche

``

Keep in mind that Hardhat 4.X also supports other features such as events, approach management and more. Be sure to see the official hardhat documentation, where you will find a comprehensive list of available hip and features.

ETHEREUM BITFINEX