I have a contract written in remix, but I am trying to deploy it using Geth's non-interactive mode using geth attach ipc:<path> -exec "<contract deploy info>"
.
When I am in interactive mode I can simply paste (without line breaks) the web3Deploy field from Remix into the console and the contract is created. But when I try to put the same info in above, I get errors of an invalid ipc path.
(Geth attach works without the contract info being executed, so I know the ipc path is correct)
This is the web3Deploy info I am using
var adderContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"newStateNum","type":"int256"}],"name":"changeNum","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function","stateMutability":"nonpayable"},{"constant":false,"inputs":[{"name":"newName","type":"string"}],"name":"changeName","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function","stateMutability":"nonpayable"},{"constant":false,"inputs":[{"name":"numToAdd","type":"int256"}],"name":"addToTotal","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function","stateMutability":"nonpayable"},{"constant":true,"inputs":[],"name":"getNum","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function","stateMutability":"view"}]);
var adder = adderContract.new(
{
from: web3.eth.accounts[0],
data: '0x6060604052341561000c57fe5b5b61039e8061001c6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632f42b8ec1461005c5780635353a2d81461009057806355da0f901461017157806367e0badb146101a5575bfe5b341561006457fe5b61007a60048080359060200190919050506101cb565b6040518082815260200191505060405180910390f35b341561009857fe5b6100e8600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506101db565b6040518080602001828103825283818151815260200191508051906020019080838360008314610137575b80518252602083111561013757602082019150602081019050602083039250610113565b505050905090810190601f1680156101635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561017957fe5b61018f600480803590602001909190505061029a565b6040518082815260200191505060405180910390f35b34156101ad57fe5b6101b56102ae565b6040518082815260200191505060405180910390f35b600081600181905590505b919050565b6101e36102b9565b81600090805190602001906101f99291906102cd565b8054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561028d5780601f106102625761010080835404028352916020019161028d565b820191906000526020600020905b81548152906001019060200180831161027057829003601f168201915b505050505090505b919050565b60008160015401600181905590505b919050565b600060015490505b90565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061030e57805160ff191683800117855561033c565b8280016001018555821561033c579182015b8281111561033b578251825591602001919060010190610320565b5b509050610349919061034d565b5090565b61036f91905b8082111561036b576000816000905550600101610353565b5090565b905600a165627a7a7230582033f26c61cd926713a470828b467ddd81bf625ada1026f21c901b0d5c22257a5f0029',
gas: '4700000'
}, function (e, contract){
console.log(e, contract);
if (typeof contract.address !== 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
})
and this is the command I use to try to deploy the contract in non-interactive mode
geth attach ipc:"\\.\pipe\%ethereum_home%\node1\geth.ipc" -exec "var adderContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"newStateNum","type":"int256"}],"name":"changeNum","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function","stateMutability":"nonpayable"},{"constant":false,"inputs":[{"name":"newName","type":"string"}],"name":"changeName","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function","stateMutability":"nonpayable"},{"constant":false,"inputs":[{"name":"numToAdd","type":"int256"}],"name":"addToTotal","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function","stateMutability":"nonpayable"},{"constant":true,"inputs":[],"name":"getNum","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function","stateMutability":"view"}]); var adder = adderContract.new( { from: web3.eth.accounts[0], data: '0x6060604052341561000c57fe5b5b61039e8061001c6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632f42b8ec1461005c5780635353a2d81461009057806355da0f901461017157806367e0badb146101a5575bfe5b341561006457fe5b61007a60048080359060200190919050506101cb565b6040518082815260200191505060405180910390f35b341561009857fe5b6100e8600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506101db565b6040518080602001828103825283818151815260200191508051906020019080838360008314610137575b80518252602083111561013757602082019150602081019050602083039250610113565b505050905090810190601f1680156101635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561017957fe5b61018f600480803590602001909190505061029a565b6040518082815260200191505060405180910390f35b34156101ad57fe5b6101b56102ae565b6040518082815260200191505060405180910390f35b600081600181905590505b919050565b6101e36102b9565b81600090805190602001906101f99291906102cd565b8054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561028d5780601f106102625761010080835404028352916020019161028d565b820191906000526020600020905b81548152906001019060200180831161027057829003601f168201915b505050505090505b919050565b60008160015401600181905590505b919050565b600060015490505b90565b602060405190810160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061030e57805160ff191683800117855561033c565b8280016001018555821561033c579182015b8281111561033b578251825591602001919060010190610320565b5b509050610349919061034d565b5090565b61036f91905b8082111561036b576000816000905550600101610353565b5090565b905600a165627a7a7230582033f26c61cd926713a470828b467ddd81bf625ada1026f21c901b0d5c22257a5f0029', gas: '4700000' }, function (e, contract){ console.log(e, contract); if (typeof contract.address !== 'undefined') { console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash); } })"