Explore Philand
  • Welcome to Phi
    • 🏝️What's Phi?
    • 🌄Mission
    • 🏃‍♀️Story
    • 🏄Phi Crew
  • ⚡Products
    • 🏝️Phi Land
      • 🔦User Guide for Phi Land
        • 0️⃣Before Playing Phi
          • 🦊Download a Crypto Wallet
          • 🟣Get $MATIC
          • 🔷Get an ENS Domain
        • 1️⃣Access Phi Land
        • 2️⃣Create your Phi Land
        • 3️⃣Claim Quest Objects
        • 4️⃣Purchase Items on Shop
        • 5️⃣Deposit Objects to Land
        • 6️⃣Build your land
        • 7️⃣Share your land on Twitter
      • 🎧Phi Music
      • ⛓️Hyperlinks & Link List
      • 💫Transferring Land
      • ↔️Phi Connect
    • ⚔️Phi Quest
      • 🔦User Guide for Phi Quest
        • 0️⃣Before Playing Phi
          • 🦊Download a Crypto Wallet
          • 🟣Get $MATIC
        • 1️⃣Access Phi Quest
        • 2️⃣Claim Quest Objects
          • Quest List
          • Adventure
          • Campaign
        • 3️⃣Purchase Items on Shop
        • 4️⃣Play Phi Land with Items you got
      • 🧑Account
      • 🏅Active Score Rank Quests
    • 🍭Phi Opportunity (beta)
    • 💎Phi Material
      • ⚒️Phi Craft
      • 🥗UGC Craft
    • 🔮OpenSea Collection Links
    • 💡How-to's
      • 🏷️Mastering ENS (Ethereum Name Service)
        • How to Register an ENS Domain Name
        • How to Renew an ENS Domain Name
        • How to Manage ENS records
          • How to set up the Avatar record in ENS
            • Using MintYourPFP to set an Avatar to an ENS name
        • How to Transfer ENS to Another Wallet
        • How to set up an ENS Subdomain
    • ❓FAQ
      • Must I have an ENS to play Phi Quest?
      • How can I get an ENS domain?
      • Why don't my ENS domains show up?
      • Can I use ENS subdomains for Phi Land?
      • What happens when I transfer ENS?
      • I can't create a land
      • Why cannot access to my land?
      • Why can't I change the baseplate?
      • Why can’t I claim Quest objects?
      • Any rewards for participating in Testnet?
      • What is Phi Quest?
      • How the Leaderboard on Phi Quest is calculated?
      • Why are there two EXPs?
      • I claimed objects on Phi Quest. How can I create my Phi Land?
      • Why can’t I see my objects in my wallet?
      • Can I trade Quest Objects?
      • Are traded objects included in my EXP calculation?
      • My EXP not showing, leaderboard not updating
      • Which browser should I use?
      • Which devices are supported?
      • How to update my Twitter OGP image (card)?
    • 📬Submit Feedback
      • Bug Report
      • Feature Request
      • User Survey
  • ⚙️DEVELOPERS
    • 🪴Create Philand
    • 🎨Objects NFT
      • ⛓️Quest Object
      • 🌾Free Object
      • 🧊Premium Object
      • 🍰Baseplate Object
      • 🧮Wallpaper Object
      • 💄Other Topics
      • 💡Appendix
    • 🛠️Use PhiMap
      • 🗺️Deposit/Withdraw
      • 🍧Save Philand
      • 👀View Function
      • 💡Appendix
    • 💝Philand API
      • ⌚Introduction
      • 🔑Authentication
        • 😄Use API key
        • 😍Get Access Token
        • 🤩Verify Access Token
        • 🤪Get Refresh Token
        • 😎Refresh JWT
      • 🫔Quest
        • 🎾Get Quest List
        • 🏀Get Quest Status
        • ⚽Trigger Eligible Check
        • 🎯Get Claimed Status
        • 🏓Get Verify Coupon
      • 🏝️Philand
        • 🫑View Philand Link
        • 🍍Get Philand Image
      • 🧸Account
        • 🍞Get Philand List
        • 👑Get PhiRank
      • 🎺Object
        • 🎸Get Object Info
      • 🦖Example Call
        • 🤠Quest Claim
      • 👔Related Links
    • 🧑‍🏫How to Verify your transaction
      • 👓Read Contract Method
      • 🚩Third-party API
      • 🦷Whitelist
    • 📄Contracts
      • 👮Audit
  • 💼Career
    • 👯Phi is hiring
  • 🔗Official links
    • Website
    • Twitter
    • Discord
    • Discourse
    • Medium
    • Github
    • Guild.xyz
    • Lenster
    • Instagram
Powered by GitBook
On this page
  • We will explain how the system works.
  • Frontend
  • Backend
  • Contract
  • * CONTROLLER can create Philand but ...
  • PlayGround

Was this helpful?

  1. DEVELOPERS

Create Philand

Making it even easier and more fun to use Ethereum.

PreviousSubmit FeedbackNextObjects NFT

Last updated 2 years ago

Was this helpful?

(ENS) is a decentralized domain name system on the Ethereum. It allows users to create human-readable names for their Ethereum addresses, making it easier for others to find and interact with them.

For example, you could use an Ethereum address with the name "philand.eth". This would make it easier for others to find and use that address. ENS is a useful tool for making Ethereum addresses more user-friendly and accessible.

PHI is a service that extends the Ethereum Name Service by allowing users to create custom, visual representations of their Ethereum addresses. With PHI, you can enhance your Ethereum experience by personalizing your address with a unique, cute "land".

Our fully customizable lands make an extra layer of ENS, making it even easier and more fun to use Ethereum.

On this page, we will discuss how we use the Ethereum Name Service (ENS) to create our "philand". We will also explain the benefits and potential of this approach.

We will explain how the system works.

Frontend

In this case, user has "oyashirazu.eth". Next, frontend requests coupon to the backend.

Backend

Our Backend system checks ENS owner, and if there are no issues, ECDSA coupon is created by the admin private key. (admin key is saved at KMS)


  const result = await ensGetOwner(provider, ensname);
  // check request address is ensowner
  if (result.toLowerCase() == address.toLowerCase()) {
     // AWS KMS documentation (https://docs.aws.amazon.com/kms/)
      const decrypted = await kms.decrypt(kmsparams).promise();
      const secretkey = decrypted.Plaintext?.toString("base64");
      const signerPvtKey = Buffer.from(secretkey!, "hex");
      const hashBuffer = generateHashBuffer(
        ["string", "address", "address"],
        [params.name, params.address, REGISTRY_CONTRACT_ADDRESS],
      );
      // use a private key stored in AWS KMS to create an ECDSA signature. 
      const coupon = createCoupon(hashBuffer, signerPvtKey);
      const responseBody = JSON.stringify({ coupon: serializeCoupon(coupon) });
      return successResponse(responseBody); //<- frontend get coupon
      }

// ens owner check
async function ensGetOwner(provider: any, name: string) {
  const ensAddr = (await provider.getNetwork()).ensAddress;
  const ensAbi = ["function owner(bytes32) view returns (address)"];
  const contract = new ethers.Contract(ensAddr, ensAbi, provider);
  const addr = await contract.owner(ethers.utils.namehash(name));
  if (addr === ethers.constants.AddressZero) {
    return null;
  }
  return addr;
}

// create Coupon functions
function createCoupon(hash: any, signerPvtKey: any) {
  return ecsign(hash, signerPvtKey);
}

function generateHashBuffer(typesArray: any, valueArray: any) {
  return keccak256(toBuffer(ethers.utils.defaultAbiCoder.encode(typesArray, valueArray)));
}

function serializeCoupon(coupon: { r: any; s: any; v: any }) {
  return {
    r: bufferToHex(coupon.r),
    s: bufferToHex(coupon.s),
    v: coupon.v,
  };
}

We are using ECDSA signatures for verification in our backend/contract.

For more information about ECDSA, please refer to the provided link.

Contract

Our frontend uses ECDSA coupons and call createPhiland method. Then, user creates a "Philand"

    /*
     * @title createPhiland
     * @notice Send create message to phimap
     * @param name : ens name
     * @dev include check ENS using coupon
     */
    function createPhiland(string memory name, Coupon memory coupon) external onlyENSOwner(name, coupon) {
        if (ownerLists[map][name] != address(0)) {
            revert AllreadyClaimedPhiland({ sender: msg.sender, owner: ownerLists[map][name], name: name });
        }
        unchecked {
            claimed++;
        }
        ownerLists[map][name] = msg.sender;
    // request the philand creation of a philand contract for name(msg.sender).
        IPhiMap _phimap = IPhiMap(map);
        _phimap.create(name, msg.sender);
        emit LogCreatePhiland(msg.sender, name);
    }
    
    // modifier checks whether the msg.sender is the owner of a specific ensname.
    modifier onlyENSOwner(string memory name, Coupon memory coupon) {
        // Check that the coupon sent was signed by the admin signer
        bytes32 digest = keccak256(abi.encode(name, msg.sender, address(this)));
        if (!isVerifiedCoupon(digest, coupon)) {
            require(isVerifiedCoupon(digest, coupon), "Invalid coupon");
        }
        _;
    }
    
    function isVerifiedCoupon(bytes32 digest, Coupon memory coupon) internal view returns (bool) {
        address signer = ecrecover(digest, coupon.v, coupon.r, coupon.s);
        if (signer == address(0)) {
            revert ECDSAInvalidSignature({ sender: msg.sender, signer: signer, digest: digest, coupon: coupon });
        }
        return signer == _adminSigner;
    }

Once these verifications are successfully completed, you will be able to obtain your ENS philand.

* CONTROLLER can create Philand but ...

When an ENS doamin is purchased at OpenSea(or other marketplace), only the REGISTRANT is transferred to your wallet and the CONTROLLER remains with the previous owner. (Because the REGISTRANT means the ownership of an ENS, the controller does not necessarily have to be the owner of that ENS.)

PlayGround

You can test philand visual experience using Playground. It is completely free and no restriction

At first, frontend checks the ENS subgraph () to see which ens do user have.

"ECDSA Signatures in Bitcoin" by Jimmy Song ()

"Elliptic Curve Digital Signature Algorithm (ECDSA)" by Andreas M. Antonopoulos ()

"ECDSA Signatures" by BitcoinWiki ()

Registry Contract ()

https://thegraph.com/hosted-service/subgraph/ensdomains/ens
https://medium.com/@jimmysong/ecdsa-signatures-in-bitcoin-cc1b4cbd85d0
https://aantonop.com/ecdsa-elliptic-curve-digital-signature-algorithm/
https://en.bitcoinwiki.org/wiki/ECDSA_Signatures
https://polygonscan.com/address/0x6532B97295a0728880AE81D5CD7248f32E24e39a
Why don't my ENS domains show up?
⚙️
🪴
The Ethereum Name Service
Phi LandPhi Land
https://playground.philand.xyz/
Logo
You can create your own ensLand.
Using graph and check users ens
Create you Philand
Page cover image