I am trying to deploy a oraclized smart contract
pragma solidity ^0.4.11;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
contract ExampleContract is usingOraclize {
string public EURGBP;
event updatedPrice(string price);
event newOraclizeQuery(string description);
function ExampleContract() payable {
updatePrice();
}
function __callback(bytes32 myid, string result) {
if (msg.sender != oraclize_cbAddress()) throw;
EURGBP = result;
updatedPrice(result);
updatePrice();
}
function updatePrice() payable {
if (oraclize_getPrice("URL") > this.balance) {
newOraclizeQuery("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
} else {
newOraclizeQuery("Oraclize query was sent, standing by for the answer..");
oraclize_query(60, "URL", "json(http://api.fixer.io/latest?symbols=USD,GBP).rates.GBP");
}
}
What the issue is, in broad strokes.
When I create a migration file and I try to deploy the contract using 'truffle migrate', I get this error.
What actually happened. Please give examples and support it with screenshots, copied output or error messages.
Experienced this issue trying to run truffle test on rinkeby testnet from gentoo linux.
I've discovered that Assert.sol generates an EVM binary that is just too big to be deployed without it choking. I ended up manually editing Assert.sol and taking out a couple of funcs that I wasn't using.
Now the EVM binary is slightly smaller and deploys on rinkeby, and my tests complete successfully.
@charltonh Your issue appears to be slightly different from the OP's, in that you're referring to Assert.sol in tests. Good news is we've fix your specific issue in Truffle 4.0 beta. :)
@salmanprk Your issue appears to be either due to the size of your contract (i.e., the code costs more gas to deploy than the default block size) or your gas amount is too low (i.e., the gas sent with your transaction isn't enough to deploy the contract). Check out our migrations documentation for more information on setting transaction parameters of individual deployments.
Cheers! Please open a new ticket if you continue to have the issue.
I have same issues, I tried to increased gas amout, but it still doesn't work.
Any other suggestions ? really annoying issue -__-
The same,
I set maximum gas allowed for rinkeby.
Transaction results in contract creations
https://rinkeby.etherscan.io/tx/0x95faddf06ba05e0a1b954a54c2ba34f6fe9b652177d81cbd99eab675680c65d1
but tx receipt fails and contract code not deployed.
`> {
"jsonrpc": "2.0",
"id": 626,
"method": "eth_getTransactionReceipt",
"params": [
"0x95faddf06ba05e0a1b954a54c2ba34f6fe9b652177d81cbd99eab675680c65d1"
]
}
< {
< "jsonrpc": "2.0",
< "id": 626,
< "result": {
< "blockHash": "0x345af884b281652182b59ed2d563dd81ff7105ffbb31e838dfaf63cc45f6b522",
< "blockNumber": "0x176b57",
< "contractAddress": "0x0e4fdb1262d1838e509dc1c3989361cf0e4d5686",
< "cumulativeGasUsed": "0x1013c1",
< "from": "0x1805d581593b31138be3bf780a17497229a2774d",
< "gasUsed": "0x1013c1",
< "logs": [],
< "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
< "status": "0x0",
< "to": null,
< "transactionHash": "0x95faddf06ba05e0a1b954a54c2ba34f6fe9b652177d81cbd99eab675680c65d1",
< "transactionIndex": "0x0"
< }
< }
{
"jsonrpc": "2.0",
"id": 627,
"method": "eth_getCode",
"params": [
"0x0e4fdb1262d1838e509dc1c3989361cf0e4d5686",
"latest"
]
}
< {
< "jsonrpc": "2.0",
< "id": 627,
< "result": "0x"
< }
{
"jsonrpc": "2.0",
"id": 628,
"method": "eth_uninstallFilter",
"params": [
"0xa63ce5039e01231dbd3e1da542d82d40"
]
}
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount.
at Object.callback (C:\Users\Alex\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:327595:46)`
So look, i got a receipt with contract address, but it truffle fail with it may be because
https://github.com/trufflesuite/truffle/issues/558
btw really small contract like migrations is deployed
my contract pretty easy, basic zeppelin contract
pragma solidity ^0.4.13;
import './AlexCoin.sol';
import 'zeppelin-solidity/contracts/crowdsale/Crowdsale.sol';
contract AlexCoinCrowdsale is Crowdsale {
function AlexCoinCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) public
Crowdsale(_startTime, _endTime, _rate, _wallet)
{
}
// creates the token to be sold.
// override this method to have crowdsale of a specific MintableToken token.
function createTokenContract() internal returns (MintableToken) {
return new AlexCoin();
}
}
pragma solidity ^0.4.13;
import 'zeppelin-solidity/contracts/token/MintableToken.sol';
contract AlexCoin is MintableToken {
string public name = "ALEX COIN";
string public symbol = "ACO";
uint256 public decimals = 18;
}
@lexruster were you able to fix your issue?
I was following the same exact tutorial as you and ran into the same issue. I was trying to deploy on ropsten and kovan.
Upon running truffle deploy --network kovan or ropsten, I get the following error:
Running migration: 1_initial_migration.js
Deploying Migrations...
... 0xe514f11e0968c3b3570f8c49383450e29552ac5374e663cf2858275c2347429e
Migrations: 0x9be30d437be261af9430fac1d0e8fdf2957a77fc
Saving successful migration to network...
... 0x2733d4c971330ce20a7a8eec34cd6136119bfd675db727402caf7d722494eab6
Saving artifacts...
Running migration: 2_deploy_contracts.js
[ 1517766299,
1518371099,
1,
'0xafd860a9ac1e1f29e1efa102f82081cd38626054' ]
Deploying FirstCrowdsale...
... 0x77e6e144a163d0de1505c340721288f0cb1b38fbfea29e310b6b3613ba8518b2Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount.
I posted here my contracts, truffle.js and deployment script. Any help would be appreciated.
pragma solidity ^0.4.19;
import "../node_modules/zeppelin-solidity/contracts/crowdsale/Crowdsale.sol";
import "../node_modules/zeppelin-solidity/contracts/token/MintableToken.sol";
import "./FirstToken.sol";
contract FirstCrowdsale is Crowdsale {
function FirstCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet)
Crowdsale(_startTime, _endTime, _rate, _wallet) public
{
}
function createTokenContract() internal returns (MintableToken) {
return new FirstToken();
}
}
pragma solidity ^0.4.19;
import "../node_modules/zeppelin-solidity/contracts/token/MintableToken.sol";
contract FirstToken is MintableToken {
string public constant name = "FirstToken"; // solium-disable-line uppercase
string public constant symbol = "FIRST"; // solium-disable-line uppercase
uint8 public constant decimals = 18; // solium-disable-line uppercase
}
require('dotenv').config();
const Web3 = require("web3");
const web3 = new Web3();
const WalletProvider = require("truffle-wallet-provider");
const Wallet = require('ethereumjs-wallet');
//export MAINNET_PRIVATE_KEY and ROPSTEN_PRIVATE_KEY in your .env
var mainNetPrivateKey = new Buffer(process.env["MAINNET_PRIVATE_KEY"], "hex")
var mainNetWallet = Wallet.fromPrivateKey(mainNetPrivateKey);
var mainNetProvider = new WalletProvider(mainNetWallet, "https://mainnet.infura.io/");
var ropstenPrivateKey = new Buffer(process.env["ROPSTEN_PRIVATE_KEY"], "hex")
var ropstenWallet = Wallet.fromPrivateKey(ropstenPrivateKey);
var ropstenProvider = new WalletProvider(ropstenWallet, "https://ropsten.infura.io/");
var kovanPrivateKey = new Buffer(process.env["ROPSTEN_PRIVATE_KEY"], "hex")
var kovanWallet = Wallet.fromPrivateKey(kovanPrivateKey);
var kovanProvider = new WalletProvider(kovanWallet, "https://kovan.infura.io/");
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
},
ropsten: {
provider: ropstenProvider,
// You can get the current gasLimit by running
// truffle deploy --network rinkeby
// truffle(rinkeby)> web3.eth.getBlock("pending", (error, result) =>
// console.log(result.gasLimit))
gas: 4600000,
gasPrice: web3.toWei("20", "gwei"),
network_id: "3",
},
kovan: {
provider: kovanProvider,
// You can get the current gasLimit by running
// truffle deploy --network rinkeby
// truffle(rinkeby)> web3.eth.getBlock("pending", (error, result) =>
// console.log(result.gasLimit))
gas: 4600000,
gasPrice: web3.toWei("21", "gwei"),
network_id: "3",
},
mainnet: {
provider: mainNetProvider,
gas: 4600000,
gasPrice: web3.toWei("20", "gwei"),
network_id: "1",
}
}
};
var FirstCrowdsale = artifacts.require("./FirstCrowdsale.sol")
// var HelloWorld = artifacts.require("./HelloWorld.sol")
module.exports = function(deployer, network, accounts) {
const BigNumber = web3.BigNumber;
const RATE = 1;
const startTime = 1517766299 ;//1517766299;
const endTime = startTime + duration.weeks(1);
console.log([startTime, endTime, RATE, accounts[0]]);
deployer.deploy(FirstCrowdsale, startTime, endTime, RATE, accounts[0]);
// deployer.deploy(HelloWorld);
};
function latestTime () {
return web3.eth.getBlock('latest').timestamp;
}
const duration = {
seconds: function (val) { return val; },
minutes: function (val) { return val * this.seconds(60); },
hours: function (val) { return val * this.minutes(60); },
days: function (val) { return val * this.hours(24); },
weeks: function (val) { return val * this.days(7); },
years: function (val) { return val * this.days(365); },
};
@sharad-s hi, did you find any solution for this?
@sharad-s @praveen7557 did you find any solution for this?
@SeptiyanAndika In my code, the problem was startingTime is less than the current time.
thanks @praveen7557
Most helpful comment
@lexruster were you able to fix your issue?
I was following the same exact tutorial as you and ran into the same issue. I was trying to deploy on ropsten and kovan.
Upon running
truffle deploy --network kovanor ropsten, I get the following error:I posted here my contracts, truffle.js and deployment script. Any help would be appreciated.
FirstCrowdSale.sol
FirstToken.sol
truffle.js
2_deploy_contracts.js