[Ethereum] How to Specify Gas Limit and Value in wei or gwei

gas-limit

Dear Anyone Who Can Help Me,

This is my first time posting and asking for help, I'm in the midst of Deploying and Running the Transactions in Remix IDE (as per the picture).

I'm stuck at the Gas Limit (as I don't know how much to put)

The same goes for Value in wei or gwei.

As I did try to enter the Gas Limit and Values, I got this error message below:

"Gas estimation failed-
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
gas required exceeds allowance (10000000) or always failing transaction"

Since on the left side, you can see my first deploy smart contract, what is your suggestion to put in Gas Limit and Value in wei or gwei?

Fyi, I'm running Injected Web3 via MetaMask.

The Code:

pragma solidity >=0.4.22 <0.6.0;

contract SWLCoin {
  // declare variables
  address owner;
  string name;
  string symbol;
  uint256 totalSWLCoins;
}

Please advice, many thanks.
enter image description here

Best Answer

Gas Limit (maximum number of gas units required for the transaction to execute):

For this contract, I believe that you won't need more than 1 million gas units. You can put 2 million, I guess there's not much harm in that except for making your transaction take longer to execute. But you cannot put more than the block limit, which is typically around 8 million, depending on what network you're deploying to (mainnet, ropsten, your own private network, etc).


Value (amount of wei-ether passed within the transaction to the contract):

Since you don't have a payable fallback function in the contract, you cannot put anything other than 0, because the transaction will fail otherwise (in fact, that's probably the reason for your error).

Related Topic