I'm trying some things out in the ethereum wallet but it keeps guessing the amount of gas wrong. How do I send more gas in the ethereum wallet?
[Ethereum] How to add more gas to transaction in the Ethereum Wallet
ethereum-wallet-dappgasmisttransactions
Related Solutions
I prefer to use geth rather than mist to interact with contracts. The command line lets you do exactly what you intend vs working through a GUI.
The first thing you need is the contract ABI. This is a piece of javascript (or JSON) which defines how you can interact with the contract. Every contract on the blockchain has one -- a simple greeter contract, Etheria, the DAO... all of them.
To get the abi, paste your contract code into a compiler e.g. https://ethereum.github.io/browser-solidity/.
This "endowment retriever" contract may be similar to what you're trying to do. When compiled, its abi is revealed to be:
[{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"getContractCreationValue","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[],"name":"sendOneEtherHome","outputs":[],"type":"function"},{"inputs":[],"type":"constructor"}]
Compile your contract and you'll get something that looks similar. (The above code will not work for your contract.)
Now that you have the ABI and the contract address, you’re ready to gain interactive access to the contract with geth.
var abi = <cut and paste the contract abi here>;
var contract = web3.eth.contract(abi).at(<contract address>);
contract.functionname();
contract.functionname.sendTransaction(...);
Hopefully the contract from which you're trying to retrieve funds contains a method for retrieving the ether and you have permission to do so. In my "endowment retriever" example, you'd do:
var tx = endowmentretriever.sendOneEtherHome.sendTransaction({from:eth.coinbase});
If you post the entire contract (use a gist, probably), I might be able to help further and/or determine if retrieval is even possible.
Good luck!
UPDATE Apr 2 2017
As pointed out by @jeff in the comment below:
One correction; in the second image, where Mist proposes 113,250 gas, that blue text is actually editable (although it's not clear at all). So you can specify the gas limit :)
Thanks @jeff!
Assuming Ethereum Wallet
I'm assuming the "wallet" in your question refers to Ethereum Wallet (Mist) as your original question did not specify "Mist".
Q: How to specify the gas when deploy a new contract in Mist?
A: When you deploy a contract in Mist (Contracts -> Deploy New Contract), you can change the Fee in the screen. This represents the gas x the estimated gas price as shown in the screen below:
Q: When I send transactions to my contract, the wallet tells me that the gas runs out, so how can I specify the gas amount when deploy a new contract?
A: You cannot specify the maximum gas in the standard Mist interface. Mist seems to try to estimate the gas required, and adds on 100,000 units of gas on top of it's estimate. In the screen below, the estimate is 13,250 gas. Mist specifies the maximum of 113,250 gas:
If you are using geth
If you are using geth
, from 2 mapped structs with an address array - push not working:
To specify gas when creating the contract:
> var twoStructsContract = web3.eth.contract(twoStructsCompiled.TwoStructs.info.abiDefinition);
> var twoStructs = twoStructsContract.new({from:web3.eth.accounts[0], data: twoStructsCompiled.TwoStructs.code, gas: 1000000},
function(e, contract) {
if (!e) {
if (!contract.address) {
console.log("Contract transaction send: TransactionHash: " +
contract.transactionHash + " waiting to be mined...");
} else {
console.log("Contract mined! Address: " + contract.address);
console.log(contract);
}
}
}
)
To specify gas when sending a transaction to your contract:
> twoStructs.add(eth.accounts[0], 123, {
from:web3.eth.accounts[0],
data: twoStructsCompiled.TwoStructs.code,
gas: 1000000
});
If you created your contract in Mist and want to send a transaction via geth
In this section, I've deployed the following code in Mist on Testnet. You can replicate this example on Testnet using the address and information below:
contract TestMistGas {
uint256 number;
function getNumber() constant returns (uint) {
return number;
}
function setNumber(uint256 _number) {
number = _number;
}
}
To then get the contract details and use it in geth
:
Get the address Mist deployed your contract to. To do this, click on your contract in Mist and copy the address. In
geth
, assign the address to a variable:> var myContractAddress = "0xf5D623C03d245D36286D97689f8dE8B629c8f46a"; undefined
Get the JSON Application Binary Interface (ABI). To do this, click on your contract in Mist, click on Show Interface. In
geth
, assign this string to a variable:> var myContractABI = [ { "constant": false, "inputs": [ { "name": "_number", "type": "uint256" } ], "name": "setNumber", "outputs": [], "type": "function" }, { "constant": true, "inputs": [], "name": "getNumber", "outputs": [ { "name": "", "type": "uint256", "value": "12345" } ], "type": "function" } ]; undefined
Create a variable that points to your contract address with the ABI functions exposed by typing the following command in
geth
:> var myContract = eth.contract(myContractABI).at(myContractAddress); undefined
You can check that you have assigned your variables correctly by typing the following command in
geth
:> myContract { address: "0xf5D623C03d245D36286D97689f8dE8B629c8f46a", allEvents: function(), getNumber: function(), setNumber: function() }
You can send a transaction to call the
setNumber()
function using the following command ingeth
:> myContract.setNumber(123, {from: eth.accounts[0], gas: 100000});
"0xc8eeba52b5970c93e8d8be91632548b1d6400b74bd6dbbc7017e08bcc0b15648"
You can check the status of your transaction using the following command in
geth
:> eth.getTransaction("0xc8eeba52b5970c93e8d8be91632548b1d6400b74bd6dbbc7017e08bcc0b15648") { blockHash: "0x964860acb5cd6af52ff01004ba471e2c5304ea47a788bc34462c973e9f969c80", blockNumber: 1000864, from: "0x3b449dfd7c15c60a45ce1d401b5a1a6081d2a400", gas: 90000, gasPrice: 20000000000, hash: "0xc8eeba52b5970c93e8d8be91632548b1d6400b74bd6dbbc7017e08bcc0b15648", input: "0x3fb5c1cb000000000000000000000000000000000000000000000000000000000000007b", nonce: 1048582, to: "0xf5d623c03d245d36286d97689f8de8b629c8f46a", transactionIndex: 1, value: 0 }
You can call the
getNumber()
function ingeth
using the following command:> myContract.getNumber() 123
Best Answer
I do not believe it is possible from the UI that the mist wallet provides. You will need to go commandline and use the geth tool. Then you can just unlock your account and perform a transaction and define the amount of gas you want to send.
RPC doc related to function sendtransaction : https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction