# Vouch DB Specs ### 🐸🀝🐸 ## Tables ### `Request` | Attribute | PK? | Type | | - | - | - | | Claimer | true | string | | Humanity | true | string | | Vouches ID | | Vouch[] | ### `Vouch` | Attribute | PK? | Type | | - | - | - | | ID | true | ID | | Voucher | | string | | Signature | | string | | Expiration Timestamp | | number | ## Requests ### POST **/add** Adds a signature generated by voucher for vouched address corresponds to humanity. Signed typed data using [EIP-712](https://eips.ethereum.org/EIPS/eip-712). Message data of the signature is of following structure: ``` struct IsHumanVoucher { address vouchedHuman; // wallet addres of requester bytes20 vouchedForHumanity; // soulbound id for which claimer applies uint256 voucherExpirationTimestamp; // when signature expires } ``` POST request should have the following **body**: ``` { signature // generated signature msgData // data signed (structure is the one given above) } ``` Voucher address is recovered using some library. [Here](https://github.com/Proof-Of-Humanity/vouch-db/blob/master/src/controllers/vouch/add.ts#L31-L34)'s how's done in current version. Here's an example of how you can generate signature using `ethers.js` but will probably be different with other libraries (this would be done on the frontend anyway): ``` const signTypedData = async ( provider, // signer with address [vouchedHuman, vouchedForHumanity, voucherExpirationTimestamp] ) => await provider._signTypedData( { name: "Proof of Humanity", chainId: 1, verifyingContract: poh.address }, { IsHumanVoucher: [ { name: "vouchedHuman", type: "address" }, { name: "vouchedForHumanity", type: "bytes20" }, { name: "voucherExpirationTimestamp", type: "uint256" }, ], }, { vouchedHuman, vouchedForHumanity, voucherExpirationTimestamp } ); ``` Additional checks before putting the vouch in db: - Is voucher in PoH? `isHuman(voucherAddress)` - Is claimer having a current request? `getClaimerRequestId(address)` - Is vouch cloned? for vouched address and humanity does it exist vouch from voucher that is not expired? - `voucherAddress != vouchedHuman` ### GET **/search** Return **non-resolved** requests with some of the following params: `claimer` - for this claimer (vouched address) `humanity` - for this humanity (vouched for humanity) `minVouches` - with this number of vouches; should be used as only param Possible additional checks: - `minVouches` does not take into account expired vouches - ### POST/DELETE **/deleteRequest** Delete request table (with vouches) corresponding to claimer and humanity. **Body**: ``` { claimer humanity } ``` If this is called only ### EXTRA? - Bot marking a request as resolved when `RenewHumanity` event is emited? ***not urgent***