I want to build a service where users can sign up (off-chain) to get credentials which give them the right to perform certain on-chain actions.

For example, lets pretend I'm building a service where someone can buy my time by holding my token (and burning it, or spending it or whatever), but I only want people who know me to be able to buy the token. So I have a site where my friends can give me their addresses, and then trading of my token will be restricted to within those addresses.

I want this list of valid owners to be updatable. How can I accomplish this?

For bonus points, lets assume the whitelist changes relatively frequently. Frequently enough that changing the contract becomes expensive. Is there a way around updating the contract itself?

  • How about a state variable of type mapping(address => bool) and functions allow(address) and deny(address) (both only callable by the owner)? – user19510 Jan 10 '18 at 1:10

So, you will need to write your own "Oracle". Your offchain application can gather the addresses, and an administrative backend, where only you have access, could be used to call a registerOwners function in the contract, that adds the address to a list of owners (be sure to provide a way of also deactivating them, if needed).

This should be tested, but in order to save gas, you could have your friends call a function that saves their address in a mapping (a kind of pre-registration), and you would just call a function that flips a boolean inside of a struct, saying that the pre-registration has been allowed.

| improve this answer | |

You can use this smart contract, with the modifier onlyAgent, which is working the same way as onlyOwner (Ownable). Agents must be approved by adding them using the addAgent method.

Your contract must inherit AgentRole


| improve this answer | |

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.