0

Contract code:

pragma solidity ^0.8.4;

contract TestContract {
    uint public variable;
    address public owner;
    
    event VarSet(uint from, uint to);

    function set_variable(uint num) public {
        require(msg.sender == owner);
        emit VarSet(variable, num);
        variable = num;
    }

    constructor() {
        owner = msg.sender;
    }
}

Web3.js:

let Web3 = require('web3');    
let net = require('net');
        
var test_abi = [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},
        {"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"from","type":"uint256"},
        {"indexed":false,"internalType":"uint256","name":"to","type":"uint256"}],"name":"VarSet","type":"event"},
    {"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},
    {"inputs":[{"internalType":"uint256","name":"num","type":"uint256"}],"name":"set_variable","outputs":[],"stateMutability":"nonpayable","type":"function"},
    {"inputs":[],"name":"variable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}];
    
        
let w3 = new Web3('/path/to/geth/goerli/geth.ipc', net);
const test_contract_addr = 'address of contract';
var test_contract = new w3.eth.Contract(test_abi, test_contract_addr);
    
test_contract.methods.set_variable(123).send({
    from: "myWallet",
    gasPrice: '50',
    gas: 35000
}).on('error', console.error)

I'm trying to call the set_variable function on a simple smart contract with the above web 3 javascript, and I am repeatedly getting the error 'validation failed: Transaction contains data, but the ABI signature could not be found: signature 11858ea3 not found'.

I've double checked with web3.eth.abi.encodeFunctionSignature that this is indeed the right function signature for set_varible(uint256).

I'm wondering if anyone would be able to replicate this issue? I've searched online for this error message and I've had no luck.

I'm running the web3.js in node and using a local geth provider over IPC.

Thanks

1
  • How did you get that error message? – Ismael Jun 24 at 5:40

Your Answer

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

Browse other questions tagged or ask your own question.