I'm developing an application using smart contracts. I wonder if it is possible to establish different states for a contract, for example:

User 1 determines a condition X, but also determines that user 2 can change this condition. User 2 finds it necessary to change the conditions of the contract, so it changes condition X from the contract to condition Y.

In order to satisfy this situation I have considered using public key cryptography, where user 1 determines that certain private keys can make changes to the contract condition.

1 Answer 1


You don't really have a cryptography problem. Ethereum authenticates the sender for you. I think the trick will be formulating who can do what.

Here's an example interpretation of your description as I understood it.

There are n states, known by a topic ID. I made them bools for simplicity.

There is an "owner" who controls who else is allowed to edit the state. You could even make this ownership transferable but I left it out for brevity.

The owner is allowed to grant to revoke user access rights.

Certain users with permission from the owner can update a state.

pragma solidity 0.4.25;

contract Conditions {

    struct Topic {
        bool state;
        address owner;
        mapping(address => bool) canChange;

    mapping(bytes32 => Topic) public topics;

    modifier onlyTopicOwner (bytes32 topic) {
        require(msg.sender == topics[topic].owner);

    modifier onlyTopicTrustee (bytes32 topic) {
        require(msg.sender == topics[topic].owner || userTopicPermission(topic, msg.sender));

    function isTopic(bytes32 topic) public view returns(bool) {
        return(topics[topic].owner != address(0));

    function userTopicPermission(bytes32 topic, address user) public view returns(bool) {
        if(!isTopic(topic)) return false;
        return topics[topic].canChange[user];

    function createTopic(bytes32 topic, bool state) public {
        Topic storage t = topics[topic];
        t.state = state;
        t.owner = msg.sender;

    function changeUserAccess(bytes32 topic, address user, bool canChange) public onlyTopicOwner(topic) {
        topics[topic].canChange[user] = canChange;

    function changeTopicState(bytes32 topic, bool state) public onlyTopicTrustee(topic) {
        topics[topic].state = state;


Hope it helps.

  • Can a contract have two owners?
    – Mutante
    Feb 16, 2019 at 21:09
  • There's actually nothing special about "owner". it only gets meaning from interpretation in the contract code. It's a de facto standard but it can mean anything we want. Here, I made the contract itself has no owner, but the individual states each have an owner because someone needs the right to manage user access. It's just a sketch to give you some ideas. Feb 17, 2019 at 0:58
  • In other words, owner is not a reserved word in Solidity. It's merely a variable name. It means whatever the contract says it means. Feb 17, 2019 at 0:59

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.