Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: The contract has no contract data option set. This is necessary to append the constructor parameters #2892

Closed
sulenn opened this issue Jun 13, 2019 · 2 comments

Comments

@sulenn
Copy link

sulenn commented Jun 13, 2019

Description

The same piece of solidity code can be deployed under web3@1.0.0-beta.35, but it is not deployable at web3@1.0.0-beta.55

Expected behavior

{ contracts:
{ 'trustieTransaction.sol': { trustieTransaction: [Object] } },
sources: { 'trustieTransaction.sol': { id: 0 } } }
abi: [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"x","type":"string"}],"name":"set","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]

bytecode: 60806040526040805190810160405280600b81526020017f48656c6c6f20576f726c640000000000000000000000000000000000000000008152506000908051906020019061004f929190610062565b5034801561005c57600080fd5b50610107565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100a357805160ff19168380011785556100d1565b828001600101855582156100d1579182015b828111156100d05782518255916020019190600101906100b5565b5b5090506100de91906100e2565b5090565b61010491905b808211156101005760008160009055506001016100e8565b5090565b90565b610462806101166000396000f3fe608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd91461005c5780634ed3885e146100ec5780636d4ce63c146101a7575b600080fd5b34801561006857600080fd5b50610071610237565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b1578082015181840152602081019050610096565b50505050905090810190601f1680156100de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a56004803603602081101561010257600080fd5b810190808035906020019064010000000081111561011f57600080fd5b82018360208201111561013157600080fd5b8035906020019184600183028401116401000000008311171561015357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506102d5565b005b3480156101b357600080fd5b506101bc6102ef565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fc5780820151818401526020810190506101e1565b50505050905090810190601f1680156102295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102cd5780601f106102a2576101008083540402835291602001916102cd565b820191906000526020600020905b8154815290600101906020018083116102b057829003601f168201915b505050505081565b80600090805190602001906102eb929190610391565b5050565b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103875780601f1061035c57610100808354040283529160200191610387565b820191906000526020600020905b81548152906001019060200180831161036a57829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106103d257805160ff1916838001178555610400565b82800160010185558215610400579182015b828111156103ff5782518255916020019190600101906103e4565b5b50905061040d9190610411565b5090565b61043391905b8082111561042f576000816000905550600101610417565b5090565b9056fea165627a7a723058205413af5a9f723bd847328a3354c8799a3fa02cc29338df0192c4bae4e4d62b380029

Account unlocked!

contract address: 0x5aE05cCDAf6E965cD4ff6E320b35DC758B133408

result:Hello World

Actual behavior

{ contracts:
{ 'trustieTransaction.sol': { trustieTransaction: [Object] } },
sources: { 'trustieTransaction.sol': { id: 0 } } }
abi: [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"x","type":"string"}],"name":"set","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]

bytecode: 60806040526040805190810160405280600b81526020017f48656c6c6f20576f726c640000000000000000000000000000000000000000008152506000908051906020019061004f929190610062565b5034801561005c57600080fd5b50610107565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100a357805160ff19168380011785556100d1565b828001600101855582156100d1579182015b828111156100d05782518255916020019190600101906100b5565b5b5090506100de91906100e2565b5090565b61010491905b808211156101005760008160009055506001016100e8565b5090565b90565b610462806101166000396000f3fe608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd91461005c5780634ed3885e146100ec5780636d4ce63c146101a7575b600080fd5b34801561006857600080fd5b50610071610237565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100b1578082015181840152602081019050610096565b50505050905090810190601f1680156100de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a56004803603602081101561010257600080fd5b810190808035906020019064010000000081111561011f57600080fd5b82018360208201111561013157600080fd5b8035906020019184600183028401116401000000008311171561015357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506102d5565b005b3480156101b357600080fd5b506101bc6102ef565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fc5780820151818401526020810190506101e1565b50505050905090810190601f1680156102295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102cd5780601f106102a2576101008083540402835291602001916102cd565b820191906000526020600020905b8154815290600101906020018083116102b057829003601f168201915b505050505081565b80600090805190602001906102eb929190610391565b5050565b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103875780601f1061035c57610100808354040283529160200191610387565b820191906000526020600020905b81548152906001019060200180831161036a57829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106103d257805160ff1916838001178555610400565b82800160010185558215610400579182015b828111156103ff5782518255916020019190600101906103e4565b5b50905061040d9190610411565b5090565b61043391905b8082111561042f576000816000905550600101610417565b5090565b9056fea165627a7a723058205413af5a9f723bd847328a3354c8799a3fa02cc29338df0192c4bae4e4d62b380029

Account unlocked!
Error: The contract has no contract data option set. This is necessary to append the constructor parameters.
at MethodEncoder.encode (/home/qiubing/桌面/chain_creator_nodejs/node_modules/web3-eth-contract/dist/web3-eth-contract.cjs.js:149:17)
at MethodsProxy.createMethod (/home/qiubing/桌面/chain_creator_nodejs/node_modules/web3-eth-contract/dist/web3-eth-contract.cjs.js:556:57)
at MethodsProxy.executeMethod (/home/qiubing/桌面/chain_creator_nodejs/node_modules/web3-eth-contract/dist/web3-eth-contract.cjs.js:534:23)
at Function.ContractMethod.send (/home/qiubing/桌面/chain_creator_nodejs/node_modules/web3-eth-contract/dist/web3-eth-contract.cjs.js:505:29)
at web3.eth.personal.unlockAccount.then (/home/qiubing/桌面/chain_creator_nodejs/lib/compileDeployCallContract.js:52:20)
at process._tickCallback (internal/process/next_tick.js:68:7)

Steps to reproduce the behavior

1. Import `web3` 、 `solc` and `net`
2. run the code

```js
  
    const solc = require('solc');

const net = require('net');
const Web3 = require("web3");

var contractCode = "pragma solidity >=0.4.0 <0.6.0;" +
"contract trustieTransaction {" +
"string public storedData = 'Hello World';" +
"function set(string memory x) payable public { storedData = x;}" +
"function get() public view returns (string memory) { return storedData;}}";

var input = {
language: 'Solidity',
sources: {
'trustieTransaction.sol': {
content: contractCode
}
},
settings: {
outputSelection: {
'': {
'
': [ '*' ]
}
}
}
}

var output = JSON.parse(solc.compile(JSON.stringify(input)))

console.log(output)

var abi = JSON.stringify(output.contracts['trustieTransaction.sol'].trustieTransaction.abi);
console.log("abi:", abi);
var bytecode = output.contracts['trustieTransaction.sol'].trustieTransaction.evm.bytecode.object;
console.log("\n\nbytecode:", bytecode);

const web3 = new Web3(new Web3.providers.IpcProvider('/home/qiubing/桌面/chain_creator_nodejs/sulenn5/geth.ipc', net));

web3.eth.getAccounts()
.then(result => {
web3.eth.personal.unlockAccount(result[0], "qiubing", 60000)
.then(() => {
console.log('\n\nAccount unlocked!')
new web3.eth.Contract(JSON.parse(abi), {
from: '0xe9bccc70d86bab75fa2989f5c2eba32d1810edef',
data: "0x" + bytecode,
gas: 4712388,
}).deploy({
// arguments: [1]
}).send().then((instance) => {

                console.log(`\n\ncontract address: `, instance.options.address);

                instance.methods.get().call({}, function (error, result) {
                    console.log('\n\nresult:' + result)
                })
            }).catch(console.log)
        });
})

```

Error Logs

Error: The contract has no contract data option set. This is necessary to append the constructor parameters.
at MethodEncoder.encode (/home/qiubing/桌面/chain_creator_nodejs/node_modules/web3-eth-contract/dist/web3-eth-contract.cjs.js:149:17)
at MethodsProxy.createMethod (/home/qiubing/桌面/chain_creator_nodejs/node_modules/web3-eth-contract/dist/web3-eth-contract.cjs.js:556:57)
at MethodsProxy.executeMethod (/home/qiubing/桌面/chain_creator_nodejs/node_modules/web3-eth-contract/dist/web3-eth-contract.cjs.js:534:23)
at Function.ContractMethod.send (/home/qiubing/桌面/chain_creator_nodejs/node_modules/web3-eth-contract/dist/web3-eth-contract.cjs.js:505:29)
at web3.eth.personal.unlockAccount.then (/home/qiubing/桌面/chain_creator_nodejs/lib/compileDeployCallContract.js:52:20)
at process._tickCallback (internal/process/next_tick.js:68:7)

Versions

  • web3.js: 1.0.0-beta.55
  • nodejs: v10.15.3
  • ethereum node: 1.8.27-stable
@nivida
Copy link
Contributor

nivida commented Jun 13, 2019

Thanks for opening this issue! You are right setting the data property in the constructor of the AbstractContract class is missing.

The workaround until this got fixed is to pass the bytecode over the deploy method of the contract:

new web3.eth.Contract(myABI).deploy({data: '0x00', arguments: []});

Edit: Sorry for the confusion I've overseen the data accessors I've defined in the AbstractContract class. Could you update your issue to a readable way? (It will help me to find out the issue you have)

@nivida nivida added Bug Addressing a bug more information needed and removed Bug Addressing a bug labels Jun 13, 2019
@sulenn
Copy link
Author

sulenn commented Jun 14, 2019

Sorry, I have solved this problem. By adjusting the position of some parameters, such as placing data in deploy. In addition, I found that by default, contract deployments need to wait for confirmation of 24 blocks or more, so it takes a lot of time. Thank you very much for your answer.

@sulenn sulenn closed this as completed Jun 14, 2019
This was referenced Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants