Launch on LexToken
LexToken is a powerfully lean ERC-20 protocol with legal engineering benefits ⚔️.
We tokenize a lot at LexDAO. Time, goods, memes … you name it, we’ve probably tried to tokenize it.
This toking-in-production has a familiar constant: obsession on settling assets as simply as e-signatures. Click and carry on. We love computational contracts running on Ethereum (`smart contracts`) and see them as great tools for lawyers to think about, starting with the humble token.
With this entry in mind, and after months of squashing code in our legal engineering community, we are pleased to release a core, comprehensive token smart contract that sits at 250 lines of Solidity. LexToken (❂).
(We even think lawyers can read LexToken and understand how it works. Even so, make sure to check our starter guide, “Learning Solidity for Attorneys” and similar education.)
To its name, LexToken is, of course, a digital asset that can be handled by smart contracts on Ethereum. But it does quite a bit more:
LexToken is Market 💸
LexToken is compiled in the latest Solidity release and syntax (0.7.4) and has functions most expect from ERC-20 tokens, adapted from the OpenZeppelin library of common extensions: burning, minting, capping, pausing & ownership.
First off: We love OpenZeppelin ❤️. Our own engineering community token ($LEX) was launched with OZ components, and OZ remains a top stop for popular contracts to break into modular pieces for developers. But it is not quite an experimental library, and in reaching a “Market” representation of Ethereum tokens today, there are a fair few features that feel important to include in LexToken to meet requests and common pain-points:
Cost-effective Deployment on Minimal Proxy: 🚀
It is not remotely reasonable for tokens to cost over $100 to test at this stage of smart contract adoption, yet this is the going rate in token generators. Thankfully, there are patterns emerging in Solidity to clone and share functionality among smart contracts, such as the EIP-1167 Minimal Proxy Contract standard, which drastically reduces deployment gas costs here. To bring LexToken deployment in line with the current Ethereum gas market, we have implemented EIP-1167 into our factory contract, making it regularly only cost $5 to deploy:
recent deploy:
Batch Mint and Transfer: 🎏
Doing a basic token airdrop often involves deploying separate smart contracts or signing consecutive transfers to a bunch of accounts. This clearly invites technical and user risks, costs a lot of gas, and is also pretty annoying!
A simple solution is just to add batch mint and transfer functions, using a loop to help execute iterative transfers and balance updates:
Gas-less Transfers with Permit(): ✨
Pulling tokens from user accounts often requires two paid transactions, (I) `approve()`, and (II) `transferFrom()`. More recently, `permit()` patterns have been coded to create off-chain, gas-less signatures that also give accounts the right to call `transferFrom`, thereby avoiding payments for approvals and repetitive UX. As this improvement is quite timely, we have included an adapted form of the EIP-2612 specification for calling `permit()` from @albertocuestacanada into LexToken:
Native Sales for ETH: ♢
Ethereum is truly a global market and this is well demonstrated by the instant entry/exit into different communities and protocols that tokens provide. Want to join a DAO? Just buy a token on Uniswap. Over it? Sell it for a fraction of a claim to socks. This is groundbreaking stuff. Still, many of these market smart contracts require a large amount of liquidity to bootstrap (i.e., assets other than your new token) and if your token represents personal services or community rights, related price volatility and market management can be a drag.
To solve for this as simply as possible, LexToken makes sales peer-to-peer. When someone wants to buy a LexToken, they can send ETH to it and instantly receive back tokens per the `saleRate` until the `saleSupply` is exhausted. These supplies and their rate in exchange for ETH are set by the `manager` of the LexToken on calling the `updateSale` function. (`manager` will often be the issuer in these cases.)
To illustrate, a LexToken might have `details` describing an offer to redeem against the issuer’s time, say, 100 TIME for 1 Hour. This tokenized offer can be programmed as a sale supply (1000 in wei) and sale rate (100) to reflect an initial offering of 1 Hour for 1 ETH, 10 Hours total for sale.
Of course, this p2p functionality does not preclude using Uniswap or other markets with LexToken. It merely adds a simple, beginner-friendly option to set fixed prices and distribute tokens for ETH. After token distribution, more dynamic pricing and the benefits of other smart contracts might become preference.
Withdrawals: ♻️
Many tokens have been lost by accidentally transferring to other token contracts. For example, and quite alarmingly, over $700,000 in tokens is essentially locked forever in the $BNB address.
By including a `withdrawToken()` function controlled by a LexToken`manager`, batches of tokens can be easily retrieved and withdrawn to a preferred account (or simply burned) in a single transaction. Borrowing from the MolochDAO v2 contract, we also included a `max` bool to make it easier to withdraw the entire balance of local tokens. Worth noting, in addition to servicing token retrieval, `withdrawToken()` can be an easy way to collect payments in tokens for a LexToken `manager`.
Special thanks to @MesquitaDaniell for flagging this extension in our final sprint.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As we continue to iterate and build LexToken for ourselves and community, we hope we can provide updates to smart contracts in parallel to the standardization efforts of OZ. Our biggest differences will likely lie in syntax and preference for single contracts to deploy assets. The more, the merrier, the brighter ☀️.
LexToken is Resolved 👩⚖️
This is where a lot of the Lex in LexToken comes from.
We are legal engineers, after all, and in fashioning a token for LexDAO use cases, we started building from lessons in our own personal token launches and related contract law questions. Two big needs: (I) Tracking offers to token purchasers (states of legal privity) and related account updates; and (II) Resolving disputes and lost balances, which are always on the table when humans and money get involved.
`Details` Data: 📜
This was a no-brainer for our legal engineers. How to prove what token issuer is offering? Straight up, just put this info as a `string` into the token contract data itself, which gets signed on deployment and can always be updated to reflect new terms or offers. Easy enough.
recent deploy terms for MusicDAO 🎵:
To jump into some hypos, let’s say Bob stamps his token “Send me 1 token for a basket of Bob’s Apples. Email bob@apples.com with proof of TX and delivery address. Refunds for bruises, no questions asked.”
Someone sends Bob a token, and he sends back a bruised apple. The evidence of their purchase of $BAPPLE and redemption to Bob under these terms is pretty plain on Ethereum. So, Bob sends another (unbruised) apple as promised. Now, if Bob wants to make this deal a bit more in his favor, he can always update his token `details` and subsequent purchasers would be faced with a traceable entry into this updated open offer contract. Legal engineering isn’t that complicated, eh!
`Resolver` Role: 👩⚖️
Losing tokens is lame UX. On deploying LexToken, anyone can select an initial `resolver` role that has the right to transfer tokens between accounts and record a `resolution` string for each TX.
Most will likely want to combine their `manager` and `resolver` role at the outset. At most basic, a `resolver` can be a friend or other trusted account serving as backstop in case you mess up a tx, your keys, or some other snafu causes you to lose tokens. (This can also be an outsourcing role, contracted to a DAO (shills LexDAO vigorously) or other service provider to help sort through these claims, fulfilling a basic arbitration function for LexToken users.)
For those that are cautious of the `resolver` role, they can be nulled at launch or at any time thereafter by the `manager` by setting the account to 0x0.
LexToken is Live ⚔️
We have deployed a LexToken factory contract on Ethereum (0x8f274b3c49F02029640B55c2E1972fbfCf445923) that is free to use and provides, in our opinion, the cheapest and most complete ERC-20 token on the market 🏭.
To add a standard legal wrapper for tokens representing offers, anyone can copy/paste this IPFS link to import terms into their LexToken `details`: https://gateway.pinata.cloud/ipfs/QmQdETTadWUXF9JwPzHWgMLjapzc13A61aUqUB9FABnmpR/pTOS.pdf (based on $CNSL ToS) 📜.
Currently, every LexToken user also gets an instant grant of 100 $LEX from our engineers as an instant feedback service to reward early users. If you maintain 10 $LEX in your wallet, you can access our telegram chat and discuss your deployment, as well as get help setting up snapshot voting, managing distributions, and other technical advice: $LEX CORPUS CHAT 🎫. You are also welcome to cast votes and direct our research and writing agenda: $LEX VOTING ☑️.
To make it easier to launch into LexToken, we have further provided a template via OpenLaw to draft an offer, e-sign and deploy with a format crafted for “social tokens”: OPENLAW SOCIAL TOKENIZER 📜.
Onward to more trustless assets!
Follow other LexDAO engineering contracts like LexToken in LEX Corpus 📙.