In my requirement I have list of whitelist domains(xyz.com, abc.com etc.) and I have to write smart contract to check the data is coming from one of our whitelisted domains...

Solution number one: Store comma separated whitelisted domains in a string and then use a library like stringutils or solidity-util and check if my newdomain is available in my whitelisted domains.

Solution number two: Store whitelisted domains in string[] and loop through the array and if my newdomain is available in my whitelisted domains array.

I am wondering which solution is better for my scenario?

Also there is one more problem, how can I validate data like http://xyz.com, www.xyz.com, xyz.com etc all of them are valid domains

1 Answer 1


Solution number three:

  • Store whitelisted domains in mapping (string => bool) whitelisted
  • Find out if a given domain is whitelisted, using if (whitelisted[domain])

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.