I have a problem with a smart contract transaction between users. Error: gas is missing.

Here is my function:

async function transactionContract() {
  let signerAddress = gettingOwnerByKey(

  let addressRecipient = "0x82A8AD5c429903c082686a307083330F99c40E53";

  const escrow = new web3.eth.Contract(
      from: "0x061A96C2b5A18b132783bF65a45BC720e6C95b2A",
  const NET_ID = "35855456";

  let tx = await escrow.methods.shifting(addressRecipient).encodeABI({
    chainId: NET_ID,
    gas: "320000",
    gasPrice: web3.utils.toWei("42", "gwei"),
    nonce:  web3.eth.getTransactionCount(signerAddress, "pending"),

  const signedContract = await web3.eth.accounts.signTransaction(

  const transactionSignature = await web3.eth.sendSignedTransaction(

I cannot understand why it will result in an error - "gas is missing"!

  • What line does cause such error message? The call to getTransactionCount is missing await. – Ismael Jan 7 at 4:50
  • ` const signedContract = await web3.eth.accounts.signTransaction( tx, "privat key" );` error here – Artem Strekalov Jan 7 at 8:31
  • Why are you assigning to tx the result of encodeABI()? Also it doesn't accept any parameter. Probably you wanted to do something like let tx = { <other fields>, data: await escrow.methods.shifting(addressRecipient).encodeABI() } instead. – Ismael Jan 7 at 15:57
  • If I write instead of encodeABI () - send (), an error pops up: "Unknown account". Tx should return data object? I did as you said, as a result, tx returns an object. But the promise also returns an error: [[PromiseResult]]: Error: "gas" is missing at _validateTransactionForSigning – Artem Strekalov Jan 8 at 10:20
  • What are you trying to do, send a transaction or sign a transaction? If you output tx before signing what does it look like? Try writing gas as an hexadecimal string web3.utils.toHex("3200"). – Ismael Jan 8 at 14:00

The following worked for me

const recipient = new web3.eth.Contract(<ABI>, <address>);

const nonce = await web3.eth.getTransactionCount(signerAddress, "pending");
const data = recipient.methods.deposit(4444).encodeABI();

const txData = {
    chainId: web3.utils.toHex('35855456'),
    from: signerAddress,
    gasPrice: web3.utils.toWei("42", "gwei"),
    gas: web3.utils.toHex('320000'),
    to: recipient.options.address,
    value: '0x',

const tx = await web3.eth.accounts.signTransaction(txData, privateKey);

await web3.eth.sendSignedTransaction(tx.rawTransaction);

const id = await recipient.methods.id().call();

console.log(`Id: ${id}`);

Where my test contract is

pragma solidity ^0.7.0;

contract Recipient {
  uint public id;

  function deposit(uint _id) public payable {
    id = _id;

  • I am the owner of a smart contract, I need to transfer the ownership of my smart contract to another wallet. I tried to do it according to your example, the transaction hash is formed, but it displays Error: Transaction has been reverted by the EVM: – Artem Strekalov Jan 10 at 19:56
  • /* my smart contract the ownership of which I want to transfer */ const recipient = new web3.eth.Contract( ABI2, "0xF36198Ce8Dfe6A5694541bb1604195A7b9E2A61D" ); – Artem Strekalov Jan 10 at 20:10
  • /* contract owner */ let signerAddress = gettingOwnerByKey( "private key" ).address; – Artem Strekalov Jan 10 at 20:10
  • /* I want this to be the new owner of my smart contract */ let addressRecipient = "0x82A8AD5c429903c082686a307083330F99c40E53"; – Artem Strekalov Jan 10 at 20:10
  • /* shifting (addressRecipient) using this method, the rights to own the smart contract are transferred */ const data = recipient.methods.shifting(addressRecipient).encodeABI(); – Artem Strekalov Jan 10 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.