-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intrinsic gas too low #540
Comments
I’ll look into this shortly. Intrinsic gas too low usually means the gasLimit is under 21000, but I’ll poke at this once I am at my computer... |
@ninabreznik Oh... Can you re-post, but this time with the entire RPC call response? Or did the node insert the "..." in the middle of it? I need the whole thing to debug... |
Thanks, @ricmoo :) Here's the full thing...
|
Ok... I think I see the problem. :) You are setting a gas limit of 750,000. But a transaction costs 21,000 + (68 * data.length) (ish; 4 gas for a zero, 68 for non-zero, most things are non-zero)... Your data is at around 65kb, so you need at least around 2.2 million gas, just to submit your transaction to the network, that isn't including any execution. So, you need a lot more gas. You might start hitting the transaction gas limit. You may need to cut down the size of your contract, or split it up... It looks like you have the optimizer disabled too; enabling it may help save you a bit too. So, basically, the "intrinsic gas too low" means your gas limit is not even enough to ask the network to consider your transaction. :) |
Thanks, @ricmoo for a quick response. I am working on an editor and am just testing it out with real world contracts.This one is from Open Zeppelin. I tried to deploy it also using Remix, where gasLimit is set to 3 000 000 and it works, but when I set overrides.gasLimit to 3 000 000 in my code, I get this error
|
Am I even sending value via constructor correctly? var instance
if (overrides) { instance = await factory.deploy(args, overrides) }
else { instance = await factory.deploy(args) } |
It works with this contract pragma solidity ^0.5.2;
import "https://gist.githubusercontent.com/ninabreznik/a66bdae5fa18c7618b445b24fe97cce0/raw/f4df88ce6d58d959b854188a6a2daa49ba641e4f/SafeMath";
/**
* @title PaymentSplitter
* @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware
* that the Ether will be split in this way, since it is handled transparently by the contract.
*
* The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each
* account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim
* an amount proportional to the percentage of total shares they were assigned.
*
* PaymentSplitter follows a _pull payment_ model. This means that payments are not automatically forwarded to the
* accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the release
* function.
*/
contract PaymentSplitter {
using SafeMath for uint256;
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
/**
* @dev Creates an instance of PaymentSplitter where each account in payees is assigned the number of shares at
* the matching position in the shares array.
*
* All addresses in payees must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in payees.
*/
constructor (address[] memory payees, uint256[] memory shares) public payable {
// solhint-disable-next-line max-line-length
require(payees.length == shares.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares[i]);
}
}
/**
* @dev The Ether received will be logged with PaymentReceived events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for [fallback functions].
*
* [fallback functions]: https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function
*/
function () external payable {
emit PaymentReceived(msg.sender, msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the address of the payee number index.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Triggers a transfer to account of the amount of Ether they are owed, according to their percentage of the
function release(address payable account) public {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = address(this).balance.add(_totalReleased);
uint256 payment = totalReceived.mul(_shares[account]).div(_totalShares).sub(_released[account]);
require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] = _released[account].add(payment);
_totalReleased = _totalReleased.add(payment);
account.transfer(payment);
emit PaymentReleased(account, payment);
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) private {
require(account != address(0), "PaymentSplitter: account is the zero address");
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(_shares[account] == 0, "PaymentSplitter: account already has shares");
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares.add(shares_);
emit PayeeAdded(account, shares_);
}
} |
What is |
I have ...args :) Just didn't want to confuse it here... You try to replicate it on https://ethereum-play.github.io/editor-solidity/ using 2 contracts mentioned above. One works fine, the other throws this error... |
Do you still have this problem? I think the problem is the length of the one contract is way longer, so the intrinsic gas required is a lot more (more than the gas limit permits). |
@dorjebro this means your gasLimit is too low. Are you setting your gasLimit explicitly? What network are you using? |
I'm using metamask how mush I should take gas limit? |
In your transaction where you are specifying the gasLimit in a transaction or contract interaction? Can you include a code snippet? |
Hi,
I am trying to deploy this contract
I am using these ethers.js calls
When I try to deploy, I get this error in Metamask. I tried with higher gasLimit but didn't help
The text was updated successfully, but these errors were encountered: