Reputation: 41
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.
Upvotes: 2
Views: 3352
Reputation: 1740
Delete .encode()
, because you should pass in a string for the address field.
Let me know if it still doesn't work!
Upvotes: 1