030ffice-logoZwart4

Ethereum’s placement script: What is not okay?

When it comes to placing smart contracts for the Ethereum blockchain, a well -designed placement script is very important. In this article, we will enter into the problem of trying to use console ads. Ilog after the module export.

question

In the example of the contract in which you are, use the module.exports notification in the example of the code passage. However, in this script you faced the problem of the console journal announcements.

`Javascript

Const {network} = ask (” hardhat ” ‘);

Const {

Development Chains,

NetworkConfig,

Initially_supply,

} = Ask (‘”../ hardhat-config’ ‘);

module.exports = {

// the contract code you are leaving here

};

`

When you run the placement script, the "console.log" ads will not be executed because they are located outside the export object.

Correction

To solve this problem, you must cover the ads connected in a statement of import or a conditioned block that will allow them to evaluate. Here is an updated version of the code fragment:

Javascript

Const {network} = ask (” hardhat ” ‘);

Const {

Development Chains,

NetworkConfig,

Initially_supply,

} = ask (‘”../ hardhat-config’ ‘);

module.exports = () => {

Console.log (‘Placing has begun!’);

if (network.Name === ‘Mainnet’) {

Console.log (‘placed on Mainnet!’);

} else if (developmentchains.include (network.name)) {

Console.log (“placed on the development chain!”);

}

Const {accounts, getcontractddres} = ask (‘../ helper-hardhat-config’);

// the contract code you are leaving here

};

`

In this updated version:

best practices

Ethereum: My deploy script won't run. Any `console.log` after `module.exports` won't work

To avoid similar problems in the future, make sure –

most confidential crypto

Leave a Reply

Your email address will not be published. Required fields are marked *