Built on Lens Network for Lens Holiday Hackathon using ConnectKit and Hardhat.
Every account in EVM has an address, derived from a public key, derived from a private key. Public key is simply a coordinate on an "elliptic-curve", so basically it is a point secp256k1
:
A curve-friendship for a pair of points t
is defined as a function
and the distance function
Here is a picture from learnmeabitcoin, where it shows how the points on a curve look like in a finite field. Basically if you are close to other points on this curve, you are friends with them!
Frencurve contract is deployed on Lens Testnet. You can interact with it as follows:
register({x, y})
with the coordinates of your public key, using the corresponding wallet.makeFrens(address, address)
with another address, permanently marking whether you are frens or not on chain!- call
frenships(address, address)
to read frenships of addresses.
We also have a simple ERC20 implementation called FrenERC20
as an example, that only allows token transfers among frens, and none other!
Install everything with:
pnpm install
Then run with:
pnpm run dev
The website should be live on http://localhost:5173/.
We are using the template, initialized with:
git clone --depth=1 --branch=master [email protected]:lens-protocol/lens-network-hardhat-boilerplate.git contracts
rm -rf ./contracts/.git
For this part, read the README within the contracts folder.
-
In the current implementation, Frencurve has a single constant that value for friendship that more or less hits a %70 friendship and %30 non-friendship over random wallets. This threshold value can be adjusted per-app.
-
We have used account public keys as identifiers as they can be used cross-chain as well. However, one can also consider ECDSA signatures as coordinates alone too, making app-specific friendships similar to the bulletpoint above.
-
The distance function to be used has many issues with the integer overflows and safe-math operations, one can definitely come up with a better algorithm!