I want Solidity code to define a function f that would map two Ethereum addresses A, B into a new address X = f(A,B) such that there is nearly zero probability that X is an already taken address (an address of an existing wallet or an address equal to f(C,D) where C!=A or D!=B.

I will explain why I want this. I want to create a token COURT that would represent decisions of several courts, each court denoted by an address. A party may endorse or not endorse the court decision. If a court B decision is enforced on a wallet A then f(A,B) is considered as a valid reservoir of money, otherwise not.

  • 2
    Just concatenate them together and hash? But I don't see how that will help... no one will be able to use that address in any meaningful way because no one will have the private key and there will be no way to deploy a contract there. You could send ether there, but you wouldn't be able to get it out.
    – user19510
    Oct 5, 2019 at 0:30
  • 2
    address(uint256(keccak256(abi.encodePacked(addressA, addressB)))) should do the "concatenate them together and hash" part. But make sure that's going to actually be useful for you.
    – user19510
    Oct 5, 2019 at 0:32
  • @smarx I don't see any trouble here. It is my contract, I can do whatever I want to do with the money (I mean my token COURT, not Ether) stored at this address, for example to transfer it to a wallet of a user that has a private key.
    – porton
    Oct 5, 2019 at 0:33
  • I mean the address you make up by combining the other two addresses. What are you going to do with address X?
    – user19510
    Oct 5, 2019 at 0:34
  • If it's just internal to your contract, why does it have to be an address at all? Why not just do mapping(address => mapping(address => uint256)) courtBalances and use courtBalances[addressA][addressB]?
    – user19510
    Oct 5, 2019 at 0:35


Your Answer

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

Browse other questions tagged or ask your own question.