I have 3 contracts: User, Patient, and Doctor. Patient and Doctor both inherit from User.


contract User { 
    // Stuff not relevant for question
    function User() {
        // Constructs 


contract Patient is User {
    mapping(bytes32 => bytes32[]) category_Records;
    mapping(bytes32 => Record) id_Record;
    // Records
    struct Record {
        bytes32 id;
        bytes32 category;
        address addedBy;
        address addedByContract;
        uint dateAdded;
        bytes32 _hash;
        bool verified;
    // Adding record
    function addRecord(bytes32 _id, bytes32 _category, bytes32 _hash) {
        Record memory newRecord = Record(_id, _category, tx.origin, msg.sender, now, _hash, false);
        id_Record[_id] = newRecord;


contract Doctor is User {
    // Adding record
    function addRecord(bytes32 patientID, bytes32 _id, bytes32 _category, bytes32 _hash) {
        // The registry bit is a registry contract which is working
        address _patient = registry.getContractAddress(patientID); 
        // From the registry we get the patient contract address
        Patient patient = Patient(_patient);
        patient.addRecord(_id, _category, _hash);

I have a button in my front-end which calls

contract.user.doctor.addRecord(publicAddress, contractAddress, pID, _id, category, hash);

which in turn calls (this function is inside an object contract.user.doctor)

function addRecord(publicAddress, contractAddress, pID, _id, category, hash) {
    const input = fs.readFileSync('contracts/All.sol').toString();
    const output = solc.compile(input);
    const bytecode = output.contracts[':Doctor'].bytecode;
    const abi = JSON.parse(output.contracts[':Doctor'].interface);
    const contract = web3.eth.contract(abi).at(contractAddress);
    // Insert gas estimation here, default prob insufficient
    contract.addRecord(patientID, _id, _category, _hash, {from: publicAddress}, (err, res) => {
        if (err) {
        } else {
            console.log('tx: ' + res);

When I click it, I get back

Error: Invalid number of arguments to Solidity function

The reason I think this is related to inheritance is because I tried, for testing, to make Doctor a standalone (not inherited) contract with only two methods, getBytes() and setBytes(). When I called from my node app, everything worked fine.

I've checked many times and there is the correct arguments to the Solidity function so I have no idea why it gives me back that error.

Any idea?

1 Answer 1


It looks like you're passing null for the first argument to the web3 contract object.

This line has pID:

function addRecord(publicAddress, contractAddress, pID, _id, category, hash) {

This one has patientID:

contract.addRecord(patientID, _id, _category, _hash, {from: publicAddress}, (err, res) => {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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