Skip to main content
added 127 characters in body
Source Link

noteNote that the gas price can fluctuate rapidly, so it is always best to check the gas price before deploying your contract. You can do this using a gas price estimator such as EthGasStation or Etherscan.

const MyContract = await ethers.getContractFactory('MyContract', signer);
const mycontract = await MyContract.deploy({
  gasPrice: 1000000000000000000, // 100 Gwei
  gasLimit: 6660666,
});

const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy({ gasPrice: 1000000000000000000, // 100 Gwei gasLimit: 6660666, }); TheThe feeData object that you mentioned in your question is a new feature that was introduced in EIP-1559. It provides a more flexible way to specify the gas fees for a transaction.

const feeData = await provider.getFeeData();

const feeData = await provider.getFeeData();

const MyContract = await ethers.getContractFactory('MyContract', signer);
const mycontract = await MyContract.deploy(feeData);

const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy(feeData); TheThe provider.getFeeData() method returns a FeeData object that contains the following information:

maxFeePerGas: The maximum fee per gas that the user is willing to pay. maxPriorityFeePerGas: The maximum priority fee per gas that the user is willing to pay.

maxFeePerGas: The maximum fee per gas that the user is willing to pay. maxPriorityFeePerGas: The maximum priority fee per gas that the user is willing to pay. gasPricegasPrice: The base fee per gas that will be paid to the miner. The maxFeePerGas and maxPriorityFeePerGas values are specified in Gwei. The gasPrice value is specified in Wei.

If you are using Hardhat, you can use the getFeeData() methoduse the getFeeData() method from the ethers package. For example:

const { getFeeData } = require('ethers');

const { getFeeData } = require('ethers');

const feeData = await getFeeData();

const feeData = await getFeeData(); OnceOnce you have the feeData object, you can pass it to the deploy() method when deploying your contract.

Here is a summary of the two methods:

Method 1: Using the feeData objectUsing the feeData object

// Get the fee data from the provider. const feeData = await provider.getFeeData();

// Get the fee data from the provider.
const feeData = await provider.getFeeData();

// Deploy the contract using the fee data.
const MyContract = await ethers.getContractFactory('MyContract', signer);
const mycontract = await MyContract.deploy(feeData);

// Deploy the contract using the fee data. const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy(feeData); Method Method 2: Using the gasPrice and gasLimit options

// Specify the gas price and gas limit. const gasPrice = 1000000000000000000; // 100 Gwei const gasLimit = 6660666;Using the gasPrice and gasLimit options

// Deploy the contract using the gas price and gas limit options. const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy({ gasPrice, gasLimit, });

// Specify the gas price and gas limit.
const gasPrice = 1000000000000000000; // 100 Gwei
const gasLimit = 6660666;

// Deploy the contract using the gas price and gas limit options.
const MyContract = await ethers.getContractFactory('MyContract', signer);
const mycontract = await MyContract.deploy({
  gasPrice,
  gasLimit,
});

note that the gas price can fluctuate rapidly, so it is always best to check the gas price before deploying your contract. You can do this using a gas price estimator such as EthGasStation or Etherscan.

const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy({ gasPrice: 1000000000000000000, // 100 Gwei gasLimit: 6660666, }); The feeData object that you mentioned in your question is a new feature that was introduced in EIP-1559. It provides a more flexible way to specify the gas fees for a transaction.

const feeData = await provider.getFeeData();

const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy(feeData); The provider.getFeeData() method returns a FeeData object that contains the following information:

maxFeePerGas: The maximum fee per gas that the user is willing to pay. maxPriorityFeePerGas: The maximum priority fee per gas that the user is willing to pay. gasPrice: The base fee per gas that will be paid to the miner. The maxFeePerGas and maxPriorityFeePerGas values are specified in Gwei. The gasPrice value is specified in Wei.

If you are using Hardhat, you can use the getFeeData() method from the ethers package. For example:

const { getFeeData } = require('ethers');

const feeData = await getFeeData(); Once you have the feeData object, you can pass it to the deploy() method when deploying your contract.

Here is a summary of the two methods:

Method 1: Using the feeData object

// Get the fee data from the provider. const feeData = await provider.getFeeData();

// Deploy the contract using the fee data. const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy(feeData); Method 2: Using the gasPrice and gasLimit options

// Specify the gas price and gas limit. const gasPrice = 1000000000000000000; // 100 Gwei const gasLimit = 6660666;

// Deploy the contract using the gas price and gas limit options. const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy({ gasPrice, gasLimit, });

Note that the gas price can fluctuate rapidly, so it is always best to check the gas price before deploying your contract. You can do this using a gas price estimator such as EthGasStation or Etherscan.

const MyContract = await ethers.getContractFactory('MyContract', signer);
const mycontract = await MyContract.deploy({
  gasPrice: 1000000000000000000, // 100 Gwei
  gasLimit: 6660666,
});

The feeData object that you mentioned in your question is a new feature that was introduced in EIP-1559. It provides a more flexible way to specify the gas fees for a transaction.

const feeData = await provider.getFeeData();

const MyContract = await ethers.getContractFactory('MyContract', signer);
const mycontract = await MyContract.deploy(feeData);

The provider.getFeeData() method returns a FeeData object that contains the following information:

maxFeePerGas: The maximum fee per gas that the user is willing to pay. maxPriorityFeePerGas: The maximum priority fee per gas that the user is willing to pay.

gasPrice: The base fee per gas that will be paid to the miner. The maxFeePerGas and maxPriorityFeePerGas values are specified in Gwei. The gasPrice value is specified in Wei.

If you are using Hardhat, you can use the getFeeData() method from the ethers package. For example:

const { getFeeData } = require('ethers');

const feeData = await getFeeData();

Once you have the feeData object, you can pass it to the deploy() method when deploying your contract.

Here is the two methods:

Method 1: Using the feeData object

// Get the fee data from the provider.
const feeData = await provider.getFeeData();

// Deploy the contract using the fee data.
const MyContract = await ethers.getContractFactory('MyContract', signer);
const mycontract = await MyContract.deploy(feeData);

Method 2: Using the gasPrice and gasLimit options

// Specify the gas price and gas limit.
const gasPrice = 1000000000000000000; // 100 Gwei
const gasLimit = 6660666;

// Deploy the contract using the gas price and gas limit options.
const MyContract = await ethers.getContractFactory('MyContract', signer);
const mycontract = await MyContract.deploy({
  gasPrice,
  gasLimit,
});
Source Link

note that the gas price can fluctuate rapidly, so it is always best to check the gas price before deploying your contract. You can do this using a gas price estimator such as EthGasStation or Etherscan.

To specify a gas price and gas limit when deploying a contract, you can use the gasPrice and gasLimit options when calling the deploy() method. For example:

const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy({ gasPrice: 1000000000000000000, // 100 Gwei gasLimit: 6660666, }); The feeData object that you mentioned in your question is a new feature that was introduced in EIP-1559. It provides a more flexible way to specify the gas fees for a transaction.

To use the feeData object to deploy a contract, you can pass it as the options object to the deploy() method. For example:

const feeData = await provider.getFeeData();

const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy(feeData); The provider.getFeeData() method returns a FeeData object that contains the following information:

maxFeePerGas: The maximum fee per gas that the user is willing to pay. maxPriorityFeePerGas: The maximum priority fee per gas that the user is willing to pay. gasPrice: The base fee per gas that will be paid to the miner. The maxFeePerGas and maxPriorityFeePerGas values are specified in Gwei. The gasPrice value is specified in Wei.

If you are using Hardhat, you can use the getFeeData() method from the ethers package. For example:

const { getFeeData } = require('ethers');

const feeData = await getFeeData(); Once you have the feeData object, you can pass it to the deploy() method when deploying your contract.

Which method you choose to use depends on your specific needs. If you are comfortable with EIP-1559, then I recommend using the feeData object. It provides a more flexible way to specify the gas fees for your transaction. However, if you are not comfortable with EIP-1559, then you can continue to use the gasPrice and gasLimit options.

Here is a summary of the two methods:

Method 1: Using the feeData object

// Get the fee data from the provider. const feeData = await provider.getFeeData();

// Deploy the contract using the fee data. const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy(feeData); Method 2: Using the gasPrice and gasLimit options

// Specify the gas price and gas limit. const gasPrice = 1000000000000000000; // 100 Gwei const gasLimit = 6660666;

// Deploy the contract using the gas price and gas limit options. const MyContract = await ethers.getContractFactory('MyContract', signer); const mycontract = await MyContract.deploy({ gasPrice, gasLimit, });