Openzeppelin-contracts: contract creation without any data provided

Created on 10 May 2018  路  8Comments  路  Source: OpenZeppelin/openzeppelin-contracts

Contract uses ERC721Token can not be deployed by truffle.

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: contract creation without any data provided
    at Object.InvalidResponse (C:\Users\Kh\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\errors.js:38:1)
    at C:\Users\Kh\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\requestmanager.js:86:1
    at C:\Users\Kh\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-core\~\truffle-migrate\index.js:225:1
    at C:\Users\Kh\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-provider\wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (C:\Users\Kh\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\Kh\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (C:\Users\Kh\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (C:\Users\Kh\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:509:1)
    at IncomingMessage.<anonymous> (C:\Users\Kh\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:469:1)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Example:

pragma solidity ^0.4.23;
import 'zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol';
contract Token is ERC721Token {
}

Geth
Version: 1.8.7-stable
Git Commit: 66432f3821badf24d526f2d9205f36c0543219de
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.10.1
Operating System: windows

truffle
Version
Solidity v0.4.23 (solc-js)

How can this be solved?

Most helpful comment

I did some investigation. Unfortunately this error message

Error: contract creation without any data provided

has nothing to do with the problem.

The other message you can get when you have abstract contract with zero number of constructor parameters is

The contract code couldn't be stored, please check your gas amount

It seems truffle throws some error messages when it is not possible to deploy contract to blockchain. In this case it is not possible to deploy because DetailedERC20 contract is an abstract contract. You have to also import StandardToken contract.

Correct code would be:

pragma solidity ^0.4.21;

import "openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol";

contract TestToken is StandardToken,DetailedERC20{

  uint public number = 256;

  constructor () DetailedERC20('test','test',18) public
  {
    number = 1;
  }
}

And you can also get this error message when you didn't provide constructor input parameters. So it is a bit tricky and error message isn't always correct.

All 8 comments

@dmitry537 I might be missing something, but it doesn't appear you've initialized your contract correctly and constructor arguments in ERC721Token.sol are going unsatisfied.

I'm new to OpenZeppelin and had a similar problem the other day. It inspired me to draft up the following. Hope it's helpful.

How To Manually Test Your OpenZeppelin Secure Smart Contracts

@dougiebuckets thanks for the answer (and the post). I'm closing it; but @dmitry537, please let us know if you have further questions.

I have my contract defined as follows and I still get exactly same error:

pragma solidity ^0.4.21;

import "openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol";

contract TestToken is DetailedERC20{

  uint public number = 256;

  constructor () public DetailedERC20('test','test',18)
  {
    number = 1;
  }
}

I get this error:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: contract creation without any data provided
    at Object.InvalidResponse (C:\Users\wild\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\errors.js:38:1)
    at C:\Users\wild\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\requestmanager.js:86:1
    at C:\Users\wild\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-migrate\index.js:225:1
    at C:\Users\wild\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-provider\wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (C:\Users\wild\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\wild\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (C:\Users\wild\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (C:\Users\wild\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:509:1)
    at IncomingMessage.<anonymous> (C:\Users\wild\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:469:1)
    at IncomingMessage.emit (events.js:164:20)
    at endReadableNT (_stream_readable.js:1062:12)
    at process._tickCallback (internal/process/next_tick.js:152:19)

Any idea ?

I think this problem is not related to 721. It seems that there are some conflict under the build of the contract with different network. Try to delete all the contract json files in the build folder and re-compile and migrate?

Hi. Thanks for reply. I tried to remove all json files and recompile and migrate again. Didn't help.
You are right. It is not related to 721. It is ERC20 token.

I did some investigation. Unfortunately this error message

Error: contract creation without any data provided

has nothing to do with the problem.

The other message you can get when you have abstract contract with zero number of constructor parameters is

The contract code couldn't be stored, please check your gas amount

It seems truffle throws some error messages when it is not possible to deploy contract to blockchain. In this case it is not possible to deploy because DetailedERC20 contract is an abstract contract. You have to also import StandardToken contract.

Correct code would be:

pragma solidity ^0.4.21;

import "openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol";

contract TestToken is StandardToken,DetailedERC20{

  uint public number = 256;

  constructor () DetailedERC20('test','test',18) public
  {
    number = 1;
  }
}

And you can also get this error message when you didn't provide constructor input parameters. So it is a bit tricky and error message isn't always correct.

robertmagier, you da real mvp

Thanks, I was struggling with the same problem and you hit the nail on the head

Thanks to @DJXia I solved my problem. It seems I renamed the contract because I changed the first letter to uppercase, that maked my tests impossible to pass because the artifacts on the build folder were different when I compiled.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LogvinovLeon picture LogvinovLeon  路  4Comments

frangio picture frangio  路  3Comments

rstormsf picture rstormsf  路  4Comments

fulldecent picture fulldecent  路  3Comments

mswezey23 picture mswezey23  路  4Comments