function claim(
    address receiver,
    bytes32 id,
    string username,
    bool verified,
    uint256 amount,
    bytes32 inviterId,
    uint256 inviteReward,
    bytes sig
  ) public whenNotPaused {
    require(users[id] == address(0));

    bytes32 proveHash = getProveHash(receiver, id, username, verified, amount, inviterId, inviteReward);
    address proveSigner = getMsgSigner(proveHash, sig);
    require(proveSigner == signer);

    users[id] = receiver;

    uint256 unclaimedReward = unclaimedRewards[id];
    if (unclaimedReward > 0) {
      unclaimedRewards[id] = 0;
      _distribute(receiver, unclaimedReward.add(amount));
    } else {
      _distribute(receiver, amount);
    }

    if (verified) {
      nameRegistry.finalizeName(receiver, username);
    } else {
      nameRegistry.registerName(receiver, username);
    }

    if (inviterId == 0) {
      return;
    }

    if (users[inviterId] == address(0)) {
      unclaimedRewards[inviterId] = unclaimedRewards[inviterId].add(inviteReward);
    } else {
      _distribute(users[inviterId], inviteReward);
    }
  }