DISCLAMER: This repo is currently under active development and is not ready to be used in production
Phone Number Service (PNS) is a protocol that allows you to associate your phone number to wallet addresses.
This repository contains the Solidity smart contracts for the PNS Protocol
The PNS Protocol comprises of several components:
-
PNS Registry
The PNS Registry contract.
The registry contract is the core function that lies at the heart of phone number resolution.
The
setPhoneRecord
function allows for initial creation of phone record. -
PNS Resolver
The PNS resolvers are responsible for setting resolvers and translating phone numbers into addresses.
The resolver functions allows for:
- setting the resolvers for the phone number
- returning the reolver details of a phone number.
The PNS Resolver mapping is adaptive to ENS EIP 2304 method with a bit of twist
//ENS
//name -> coinType-> encodedAddressInBytes
mapping(bytes32 => mapping(uint256 => bytes)) versionable_addresses;
//PNS
//name -> coinType-> string
mapping(bytes32 => mapping(uint256 => string)) _resolveAddress;
PNS Guardian
The PNS Guardian contract is the entry point for record creation and it's responsible for verification of phone numbers.
The setVerificationStatus
function updates user authentication state after verifying an otp onchain through it's signature using ECDSA verification scheme. The Guardian contract is the only authotized contract to access the guardian.
The smart contracts are stored under the contracts
directory.
Files marked with an asterisk (*) are specific to sound.xyz,
but you can refer to them if you are building contracts to interact with them on-chain,
or building your own customized versions.
contracts/
├── Interface
│ ├── IPNSGuardian.sol * ─ "PNS Guardian Interface"
│ ├── IPNSRegistry.sol * ─ "PNS Registry implementation interface"
│ ├── IPNSResolver.sol * ─ "PNS Resolver implementation interface"
├── PNSGuardian.sol * ─ "PNS Guardian implementation for phone number verification"
├── PNSRegistry.sol * ─ "PNS Registry logic for phone number records"
├── PNSResolver.sol * ─ "Responsible for resolving phone numbers to addresses"
├── PriceOracle.sol * ─ "Handles price calculations and interacts with chainlink oracle for price conversions"
A comprehensive documentation is currently in the works.
- git
- nodeJS
- brew
- foundry - You can run
sh ./setup.sh
to install Foundry and its dependencies. - Hardhat
-
Clone the repository
git clone https://github.com/pnslabs/pns-contracts.git cd pns-contracts
-
Install packages
yarn
-
Build contracts
```
yarn build
```
Create a .env in the root with:
PRIVATE_KEY=PRIVATE_KEY
ALCHEMY_API_KEY=
Then run:
yarn run deploy:ethereum_goerli
yarn run test
MIT Copyright 2022 PNS Labs