huffd1
is a non-fungible token implementation in Huff, where the ownership of a token is given by the evaluation of a polynomial 0xffffffffffffffffffffffffffffffffffffffd1
(hence the name), the largest 160-bit prime. Note that we could also use
The concept works for any order actually, but we would like to use an order that can fit almost all the addresses.
- have polynomial for approvals too?
- maybe use FFI to generate the basis based on total supply via script?
- bug with memory offsets somehow?
Let's describe each function:
To find the owner of a token
Initially, all tokens are owned by the contract deployer, which can be represented by the constant polynomial that is equal to the owner address.
To find the balance of an address, iterate over all tokens and call ownerOf
, counting the number of matching addresses along the way.
To transfer a token
This operation results in multiplying the coefficients of MULMOD
, and afterwards summation of the coefficients of ADDMOD
.
Also note that