4

I have some simple Solidity code to test contract deployment and invocation. It has methods to write a value to storage, and a method to read it. This worked perfectly well with a private chain with a geth client.

After switching over to Parity client and a Proof-of-Authority chain, the contract is not getting deployed because the transaction to deploy it does not get mined. I have tried increasing the gas to 600 mil and gasPrice offered to 10 Gwei. Simple transfers of Ether do go through. Also, the Solidity code compiled successfully. Tried with sending account unlocked, and also by entering account password in confirmation window in browser UI.

Contract code:

pragma solidity ^0.4.7;

contract owned {
  address owner;
  function owned() {
    owner = msg.sender;
  }
}

contract mortal is owned {
  function kill() {
    if (msg.sender == owner) selfdestruct(owner);
  }
}

contract IdMgmt is mortal {

  struct acl {
    string dataType;
    string permissions;
  }

  mapping (address => acl) public aclOf;

  function IdMgmt() { }

  function createId(address _user, string _dataType, string _permissions) {
    aclOf[_user].dataType = _dataType;
    aclOf[_user].permissions = _permissions;
  }

  function getPermissions(address _user, string _dataType) constant
    returns (string userPermissions) {

    if (stringsEqual(aclOf[_user].dataType, _dataType)) {
      userPermissions = aclOf[_user].permissions;
    }
    else {
      userPermissions = "NO DATA";
    }
  }

  function stringsEqual(string _a, string _b) internal returns (bool) {
    bytes memory a = bytes(_a);
    bytes memory b = bytes(_b);
    if (a.length != b.length) {
      return false;
    }
    for (uint i = 0; i < a.length; i ++) {
      if (a[i] != b[i]) return false;
    }
    return true;
  }
}

What other information would help in getting to the root cause?

  • 1
    Hmm... I tried sending the contract deployment transaction to another peer node on the chain. This time, it did get mined. So I guess it is up to me now to figure out what is wrong on the node where it does not get mined. – Ajoy Bhatia Feb 24 '17 at 22:06
  • This issue was seen when I tried to deploy the contract with either the JSON RPC API or with the Parity browser UI. Instead, I tried deploying with Parity's web3 Javascript API (with the Javascript code running as a NodeJS app) and that consistently works. The contract deployment transaction is mined, and code exists at the assigned address. – Ajoy Bhatia Mar 11 '17 at 1:13
  • If this resolves your issue feel free to answer your own question. – Waqar Lim Mar 22 '17 at 10:56
1

This issue was seen when I tried to deploy the contract with either the JSON RPC API or with the Parity browser UI. Instead, I tried deploying with Parity's web3 Javascript API (with the Javascript code running as a NodeJS app) and that consistently works. The contract deployment transaction is mined, and code exists at the assigned address.

  • 1
    Do you feel that it is really solved by this approach? I have the same problem and would like to use different interfaces like browser UI, browser-solidity, web3.py etc. I found out that it depends on the account I am using, with the signer accounts it works, with the user accounts it doesn't: ethereum.stackexchange.com/questions/13506/… – Ice09 Mar 25 '17 at 8:51
  • Well, yes. It does not solve the original problem but this was enough for me. I was using the JSON RPC API and the browser UI only as development tools but the project only required the web3 JS interface to work. So I did not need to leave this open. I see that you have submitted a question describing your problem, so we can let this be. (See my comment on your question re: a possible cause) – Ajoy Bhatia Mar 26 '17 at 22:15

Your Answer

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

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