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

The code in public_tx.js under the Deploy a smart contract operation in the Tutorials module of Private networks has significant errors, resulting in various errors when running node public_tx.js. #1546

Open
haerker opened this issue Mar 27, 2024 · 6 comments

Comments

@haerker
Copy link

haerker commented Mar 27, 2024

The code in public_tx.js under the Deploy a smart contract operation in the Tutorials module of Private networks has significant errors, resulting in various errors when running node public_tx.js.

            throw new web3_errors_1.InvalidResponseError(response, payload);
                  ^

InvalidResponseError: Returned error: Transaction processing could not be completed due to an exception
at Web3RequestManager._processJsonRpcResponse (/home/haerker/besu/Permissioned-Network/node_modules/web3-core/lib/commonjs/web3_request_manager.js:258:23)
at Web3RequestManager. (/home/haerker/besu/Permissioned-Network/node_modules/web3-core/lib/commonjs/web3_request_manager.js:156:29)
at Generator.next ()
at fulfilled (/home/haerker/besu/Permissioned-Network/node_modules/web3-core/lib/commonjs/web3_request_manager.js:21:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
innerError: {
code: -32000,
message: 'Transaction processing could not be completed due to an exception'
},

@macfarla macfarla transferred this issue from hyperledger/besu Mar 27, 2024
@dviejokfs
Copy link

Same happens to me, still no luck

@zariqimn
Copy link

zariqimn commented Apr 2, 2024

it was successful the first time i ran it. when I tried running it again got this error

@barcellosrod
Copy link

It´s happening the same when I try to deploy a new contract:

public.js
`
const { Web3 } = require('web3');
const { tx } = require("@ethereumjs/tx");
const path = require('node:path');
const fs = require('fs-extra');

const web3Instance = new Web3('http://myserver:8541');
// use an existing account, or make an account

const privateKey =
"0x014fc0262f554c0b98e7723331ca808fb35883b0478c55d36a1bac566850ed79";
const account = web3Instance.eth.accounts.privateKeyToAccount(privateKey);
console.log('Account Data ==>', account);
console.log('Account Address ==>',account.address);

// read in the contracts
const contractJsonPath = path.resolve('PathToContract','MyFile.json');
const contractJson = JSON.parse(fs.readFileSync(contractJsonPath));
const contractAbi = contractJson.abi;
const contractBinPath = path.resolve('PathToContract','MyFile.bin');
const contractBin = fs.readFileSync(contractBinPath);
createAndSign();

// get txnCount for the nonce value
async function createAndSign() {
const txnCount = await web3Instance.eth.getTransactionCount(account.address);
console.log('TX Account ==>',txnCount);

const rawTxOptions = {
nonce: web3Instance.utils.numberToHex(txnCount),
from: account.address,
to: null, //public tx
value: "0x00",
data: "0x" + contractBin, // contract binary appended with initialization value
gasPrice: "0x0", //ETH per unit of gas
gasLimit: "0x24A22", //max number of gas units the tx is allowed to use
};

console.log("Signing the txn")
const signedTx = await web3Instance.eth.accounts.signTransaction(rawTxOptions, privateKey);
console.log('Txn Signed ==> ',signedTx.rawTransaction);

console.log("Sending transaction...");
const pTx = await web3Instance.eth.sendSignedTransaction(signedTx.rawTransaction);
console.log('Transaction sent ==>', pTx.contractAddress);
`
Log ==>

`
PS C:\smart_contracts> node .\public.js
Account Data ==> {
address: '0xf81469f0044b8A6A670217eFef758A4B1dff8fAC',
privateKey: '0x014fc0262f554c0b98e7723331ca808fb35883b0478c55d36a1bac566850ed79',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
}
Account Address ==> 0xf81469f0044b8A6A670217eFef758A4B1dff8fAC
TX Account ==> 0n
Signing the txn
Txn Signed ==> 0xf90bdf808083024a228080b90b8f608060405234801561001057600080fd5b50600180546001600160a01b03191633179055610b5d806100326000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063298daf5b14610067578063303904141461010d57806330b39a62146101ca5780633a51d246146102705780638e27d719146103265780639b80b050146103cc575b600080fd5b61010b6004803603602081101561007d57600080fd5b810190602081018135600160201b81111561009757600080fd5b8201836020820111156100a957600080fd5b803590602001918460018302840111600160201b831117156100ca57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506104f7945050505050565b005b6101b16004803603602081101561012357600080fd5b810190602081018135600160201b81111561013d57600080fd5b82018360208201111561014f57600080fd5b803590602001918460018302840111600160201b8311171561017057600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061065c945050505050565b6040805192835290151560208301528051918290030190f35b61010b600480360360408110156101e057600080fd5b810190602081018135600160201b8111156101fa57600080fd5b82018360208201111561020c57600080fd5b803590602001918460018302840111600160201b8311171561022d57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610683915050565b6103146004803603602081101561028657600080fd5b810190602081018135600160201b8111156102a057600080fd5b8201836020820111156102b257600080fd5b803590602001918460018302840111600160201b831117156102d357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610850945050505050565b60408051918252519081900360200190f35b61010b6004803603604081101561033c57600080fd5b810190602081018135600160201b81111561035657600080fd5b82018360208201111561036857600080fd5b803590602001918460018302840111600160201b8311171561038957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610941915050565b61010b600480360360608110156103e257600080fd5b810190602081018135600160201b8111156103fc57600080fd5b82018360208201111561040e57600080fd5b803590602001918460018302840111600160201b8311171561042f57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561048157600080fd5b82018360208201111561049357600080fd5b803590602001918460018302840111600160201b831117156104b457600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610b0e915050565b6001546001600160a01b0316331461050e57600080fd5b6000816040518082805190602001908083835b602083106105405780518252601f199092019160209182019101610521565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001015460ff16159150610580905057600080fd5b600080826040518082805190602001908083835b602083106105b35780518252601f199092019160209182019101610594565b51815160209384036101000a600019018019909216911617905292019485525060405193849003810184209490945550508251600192600092859290918291908401908083835b602083106106195780518252601f1990920191602091820191016105fa565b51815160209384036101000a60001901801990921691161790529201948552506040519384900301909220600101805460ff191693151593909317909255505050565b80516020818301810180516000825292820191909301209152805460019091015460ff1682565b6001546001600160a01b0316331461069a57600080fd5b6000826040518082805190602001908083835b602083106106cc5780518252601f1990920191602091820191016106ad565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001015460ff16915061070b905057600080fd5b6000826040518082805190602001908083835b6020831061073d5780518252601f19909201916020918201910161071e565b51815160209384036101000a600019018019909216911617905292019485525060405193849003810184205486519094869450600093508792909182918401908083835b602083106107a05780518252601f199092019160209182019101610781565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020600001540311156107e357600080fd5b806000836040518082805190602001908083835b602083106108165780518252601f1990920191602091820191016107f7565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922080549390930390925550505050565b6001546000906001600160a01b0316331461086a57600080fd5b6000826040518082805190602001908083835b6020831061089c5780518252601f19909201916020918201910161087d565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001015460ff1691506108db905057600080fd5b6000826040518082805190602001908083835b6020831061090d5780518252601f1990920191602091820191016108ee565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054949350505050565b6001546001600160a01b0316331461095857600080fd5b6000826040518082805190602001908083835b6020831061098a5780518252601f19909201916020918201910161096b565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001015460ff1691506109c9905057600080fd5b6000826040518082805190602001908083835b602083106109fb5780518252601f1990920191602091820191016109dc565b51815160209384036101000a600019018019909216911617905292019485525060405193849003810184205486519094869450600093508792909182918401908083835b60208310610a5e5780518252601f199092019160209182019101610a3f565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060000154011015610aa157600080fd5b806000836040518082805190602001908083835b60208310610ad45780518252601f199092019160209182019101610ab5565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922080549390930190925550505050565b610b188382610683565b610b228282610941565b50505056fea2646970667358221220e8bd4077a590bace5a50cc5a42672036cb7e37942ee6b698543f4a3f2f8086b964736f6c63430007030033820ff1a0e5760aa332e607b66596c99a9ce395f109228fbc255292b1a11bad26607a9787a00c89d355f8e6f1860735b61ebd7df41eff216cbcdbb11124863fd95e2c5e3054
Sending transaction...
C:\smart_contracts\node_modules\web3-core\lib\commonjs\web3_request_manager.js:258
throw new web3_errors_1.InvalidResponseError(response, payload);
^

InvalidResponseError: Returned error: Internal error
at Web3RequestManager._processJsonRpcResponse (C:\smart_contracts\node_modules\web3-core\lib\commonjs\web3_request_manager.js:258:23)
at Web3RequestManager. (C:\smart_contracts\node_modules\web3-core\lib\commonjs\web3_request_manager.js:156:29)
at Generator.next ()
at fulfilled (C:\smart_contracts\node_modules\web3-core\lib\commonjs\web3_request_manager.js:21:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
innerError: { code: -32603, message: 'Internal error' },
code: 101,
data: undefined,
request: {
jsonrpc: '2.0',
id: '1f225eef-9716-4a15-89a5-165f1a620b33',
method: 'eth_call',
params: [
{
nonce: '0x0',
gasPrice: '0x0',
value: '0x0',
data: '0x608060405234801561001057600080fd5b50600180546001600160a01b03191633179055610b5d806100326000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063298daf5b14610067578063303904141461010d57806330b39a62146101ca5780633a51d246146102705780638e27d719146103265780639b80b050146103cc575b600080fd5b61010b6004803603602081101561007d57600080fd5b810190602081018135600160201b81111561009757600080fd5b8201836020820111156100a957600080fd5b803590602001918460018302840111600160201b831117156100ca57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506104f7945050505050565b005b6101b16004803603602081101561012357600080fd5b810190602081018135600160201b81111561013d57600080fd5b82018360208201111561014f57600080fd5b803590602001918460018302840111600160201b8311171561017057600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061065c945050505050565b6040805192835290151560208301528051918290030190f35b61010b600480360360408110156101e057600080fd5b810190602081018135600160201b8111156101fa57600080fd5b82018360208201111561020c57600080fd5b803590602001918460018302840111600160201b8311171561022d57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610683915050565b6103146004803603602081101561028657600080fd5b810190602081018135600160201b8111156102a057600080fd5b8201836020820111156102b257600080fd5b803590602001918460018302840111600160201b831117156102d357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610850945050505050565b60408051918252519081900360200190f35b61010b6004803603604081101561033c57600080fd5b810190602081018135600160201b81111561035657600080fd5b82018360208201111561036857600080fd5b803590602001918460018302840111600160201b8311171561038957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610941915050565b61010b600480360360608110156103e257600080fd5b810190602081018135600160201b8111156103fc57600080fd5b82018360208201111561040e57600080fd5b803590602001918460018302840111600160201b8311171561042f57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561048157600080fd5b82018360208201111561049357600080fd5b803590602001918460018302840111600160201b831117156104b457600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610b0e915050565b6001546001600160a01b0316331461050e57600080fd5b6000816040518082805190602001908083835b602083106105405780518252601f199092019160209182019101610521565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001015460ff16159150610580905057600080fd5b600080826040518082805190602001908083835b602083106105b35780518252601f199092019160209182019101610594565b51815160209384036101000a600019018019909216911617905292019485525060405193849003810184209490945550508251600192600092859290918291908401908083835b602083106106195780518252601f1990920191602091820191016105fa565b51815160209384036101000a60001901801990921691161790529201948552506040519384900301909220600101805460ff191693151593909317909255505050565b80516020818301810180516000825292820191909301209152805460019091015460ff1682565b6001546001600160a01b0316331461069a57600080fd5b6000826040518082805190602001908083835b602083106106cc5780518252601f1990920191602091820191016106ad565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001015460ff16915061070b905057600080fd5b6000826040518082805190602001908083835b6020831061073d5780518252601f19909201916020918201910161071e565b51815160209384036101000a600019018019909216911617905292019485525060405193849003810184205486519094869450600093508792909182918401908083835b602083106107a05780518252601f199092019160209182019101610781565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020600001540311156107e357600080fd5b806000836040518082805190602001908083835b602083106108165780518252601f1990920191602091820191016107f7565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922080549390930390925550505050565b6001546000906001600160a01b0316331461086a57600080fd5b6000826040518082805190602001908083835b6020831061089c5780518252601f19909201916020918201910161087d565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001015460ff1691506108db905057600080fd5b6000826040518082805190602001908083835b6020831061090d5780518252601f1990920191602091820191016108ee565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054949350505050565b6001546001600160a01b0316331461095857600080fd5b6000826040518082805190602001908083835b6020831061098a5780518252601f19909201916020918201910161096b565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092206001015460ff1691506109c9905057600080fd5b6000826040518082805190602001908083835b602083106109fb5780518252601f1990920191602091820191016109dc565b51815160209384036101000a600019018019909216911617905292019485525060405193849003810184205486519094869450600093508792909182918401908083835b60208310610a5e5780518252601f199092019160209182019101610a3f565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060000154011015610aa157600080fd5b806000836040518082805190602001908083835b60208310610ad45780518252601f199092019160209182019101610ab5565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922080549390930190925550505050565b610b188382610683565b610b228282610941565b50505056fea2646970667358221220e8bd4077a590bace5a50cc5a42672036cb7e37942ee6b698543f4a3f2f8086b964736f6c63430007030033',
from: '0xf81469f0044b8a6a670217efef758a4b1dff8fac',
gas: '0x24a22'
},
'latest'
]
}
}

Node.js v18.16.0
`

Does anyone have any ideas about this problem?

@Iamknownasfesal
Copy link

Was anyone able to use it?

@Giridharan-Govindaraj
Copy link

Hi, I am also getting the same issue while trying to deploy a contract on QBFT private network using Web3j with the generated smart contract wrapper. When I check the log with TRACE flag , it showed as "MessageFrame evaluation halted because of INVALID_OPERATION".

I am quite not sure why is this happening..

@joaniefromtheblock joaniefromtheblock removed their assignment Oct 29, 2024
@joaniefromtheblock
Copy link
Contributor

Several potential issues identified (from error message):

  • Gas price set to zero (gasPrice: "0x0")
  • Transaction might be failing due to insufficient funds
  • Network connection or configuration issues
  • Node might not be properly synced or running

Environment

Suggested fix

Update the transaction configuration to include proper gas handling:

const rawTxOptions = {
    nonce: web3Instance.utils.numberToHex(txnCount),
    from: account.address,
    to: null,
    value: "0x00",
    data: "0x" + contractBin,
    // Dynamic gas pricing
    gasPrice: await web3Instance.eth.getGasPrice(),
    // Estimate required gas
    gas: await web3Instance.eth.estimateGas({
        from: account.address,
        data: "0x" + contractBin
    })
};

Verification steps

Confirm network connection:

await web3Instance.eth.net.isListening();

Check account balance:

const balance = await web3Instance.eth.getBalance(account.address);
console.log("Balance:", web3Instance.utils.fromWei(balance, 'ether'), "ETH");

Verify current gas price:

const gasPrice = await web3Instance.eth.getGasPrice();
console.log("Gas Price:", gasPrice);

Advice for additional troubleshooting

  • Verify node is running and accessible at specified URL
  • Ensure account has sufficient funds for deployment
  • Check if using correct network/chain ID
  • Verify contract compilation was successful
  • If using private network, confirm mining is enabled

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

7 participants