2

I have written a smart contract function using solidity consisting of different parameters given below

function addDevice(address _address, string _deviceType, string _deviceName, string _minerID, string _deviceID) public
{
    DeviceData storage device = devices[_address];

    device.deviceType = _deviceType;
    device.deviceName = _deviceName;
    device.minerID = _minerID;
    device.deviceID = _deviceID;

    devicesAddresses.push(_address) -1;
}

I am using web3.py to call this function with the given commands as

D_Address = input("Device Address ").encode()
D_Type = input("Device Type ")
D_Name = input("Device Name ")
M_ID = input("Miner ID ")
D_ID = input("Device ID ")


tx_hash = contract_instance.functions.addDevice(D_Address,D_Type,D_Name,M_ID,D_ID).transact()
tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)

In REMIX, this smart contract is working fine, but when I run the file, it shows the following error

Found 1 function(s) with the name addDevice: ['addDevice(address,string,string,string,string)'] Function invocation failed due to no matching argument types.

1 Answer 1

1

Delete .encode(), because you should pass in a string for the address field.

Let me know if it still doesn't work!

Sign up to request clarification or add additional context in comments.

2 Comments

After deleting the .encode, its shows the following error '''web3.exceptions.InvalidAddress: ('Web3.py only accepts checksum addresses. The software that gave you this non-checksum address should be considered unsafe, please file it as a bug on their platform. Try using an ENS name instead. Or, if you must accept lower safety, use Web3.toChecksumAddress(lower_case_address).', '0x5fa806f48a26b45904b77b2f5382ef7a1e834699')'''
Yeah, just transform it into the checksum address, after that, I think it should work! @KhizarHameed

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.