contract Tenants{

  address admin;
  uint256[] public tenatIDs;
  mapping(bytes32 => Tenant) tenantDetails;

  function Tenants() public{

      admin = msg.sender;

  struct Tenant{

      string uniqueID;
      string name;
      uint256 flatNum;
      uint256 phoneNum;
      uint256 advanceAmt;
      uint256 rent;

  function addTenant(**Tenant tenantObj**) public{
          //code goes here


1 Answer 1


No, functions can only accept parameters of types known to the contract. You could create a JSON string in javascript and pass that, then somehow deconstruct it in your contract, but I suspect this would be very expensive to do. It would make a lost more sense to only pass the relevant data as independent variables.

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.