I'm trying to deploy a contract by two different ways, I can't succeed in any.
First way:
1. geth console —rinkeby —rpc —rpcapi db,eth,net,web3,personal —unlock="0x..." 2>>geth.log
I have ether on my account, I enter my password correctly, I'm sure that account is on eth.accounts list
2. I compile my contract with solc
, it gives me binary code and abi, which I put into variables bin
and abi
. I put 0x
before binary code.
3. var contract = web3.eth.contract(abi)
4. var token = myContract.new( {from: eth.coinbase, data: bin, gas: 1000000}, function(e, myContract) { if (e) { console.log(e); } else { if (myContract.address) { console.log ("mined " +myCcontract.address); } } })
And it says that
Error: The contract code couldn't be stored, please check your gas amount.
Second way is by using Truffle. I've succeeded in deploying contract to rinkeby lots of times already, but now I'm stuck on this error.
1. I run geth
and unlock account
2. There is my truffle.js
:
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*", gas: 900000 },
rinkeby: {
host: '127.0.0.1',
port: 8545,
network_id: 4,
gas: 4612388, // Gas limit used for deploys
from: "0xeb1eb48fc3c2756cde3dce8a53472e437062f976" } } };
3.truffle migrate --reset --network rinkeby
And it says
Error encountered, bailing. Network state unknown. Review successful transactions manually. TypeError: contract.detectNetwork is not a function at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:201861:21 at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:326484:15 at
My purpose was to learn how to interact with contract's functions by geth or truffle console. But smth went wrong. Please, help me fix it.
If you made it to the end of this question, thanks already