npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vporton/wrap-tokens

v2.1.7

Published

Wrap/lock different kinds of Ethereum tokens in other tokens

Downloads

4

Readme

Wrap Tokens

https://erc1155.portonvictor.org

TD;DR: You use this system either for (or for both):

  • wrap any ERC1155 in ERC20 or vice versa
  • use an advanced smart wallet (earn, invest, recovery of a lost account, set daily transfer limits, use human-readable addresses, no transaction fees, easy DeFi, etc., etc.) instead of a plain Ethereum account
  • bequest your funds for science and free software (please do!), you can even keep doing DeFi (earn interest) while your funds are on our "bequest" account and choose to bequest to us your interest, too

Features:

  • Wrap/lock different kinds of Ethereum tokens in other tokens.
  • Provide smart wallets for DeFi.

It provides interface between ERC20 <-> ERC1155 through both (for your choice):

  • locked tokens
  • wrapped tokens (with a bug: events are not emitted)

See also

  • frontend/README.md
  • https://youtu.be/PtfXC8ax8eI

The smart wallet usage

This project has a smart contract that can take funds from your wallet in a point of a future. The funds from your wallet go to supporting science and free software. (It uses prediction markets with conditional tokens for the users of that contract to be able to profit from your contribution before it is unlocked. It is essentially a transfer of money from the future using mathematical equalities to which markets conform, without a time-machine.) You can put your funds in that system (using a special smart contract call). If the point of the future when the funds are unlocked is not yet passed (and it is planned to be 100 years future from now!), then you can at any moment take your funds back. It provides a mean of bequest: Please put (when that contract will be deployed on mainnet), all (or at least some) your funds at that contract. While you are alive, you can take your funds back at any time. But if you die (or lose the private key), our contract will take your funds and use for charitable purposes.

For us to be able to take your bequested funds, please don't forget to approve every ERC-20 token that you wrap in our ERC-1155 contracts to be spent by our charity.

It is complicated by the fact that our charitable contract uses ERC-1155 tokens. No problem: We provide contracts that can "transform" ERC-20 to ERC-1155 (TODO: UI to do it easily while donating). So please use a contract from this package (or to-be-developed frontend) to put your ERC-20 tokens (and ETH) into it and donate or bequest the magically created ERC-1155 token. Just do it for the charity. You lose nothing: You won't need your tokens after 100 years, but we need it.

Well, there were two more problems:

  • You could not use the bequested tokens directly if you need them, but would need first withdraw them from the system. (You can do at any time, but that's inconvenient.)
  • You could not use the bequested tokens for a DeFi earn interest, because they are not on your wallet but on ours and you would not receive the interest.

The problems can be solved by using a ERC1155 wrapper over a smart wallet! For example, you can earn DeFi interest from a DeFi token put on such a wallet. Moreover, we will inherit your earned interest, too.

FAQ

Can it happen that my bequest for science will be taken before the set time passes?

No, the smart contract are written in such a way, that we can increase but can't decrease the period of time we can't take your funds.

Smart Contracts

We have the following smart contracts:

  • ERC1155LockedERC20 - you can swap (and swap back) any ERC-20 token to a ERC-1155 token whose ID is just the contract address of the ERC-20.
  • ERC1155OverERC20 - you give pemission to this contract transfer ERC-20 as if it were a ERC-1155 token (whose ID is just the contract address of the ERC-20), that is when you transfer this ERC-1155, the ERC-20 is transferred too, and vice versa. Non-fixable bug: This ERC-1155 does not emit events on transfers (because we can't emit every event the standard requires, as it would involve emitting an event for every token holder on the net when you initialize it, what is clearly impossible).

and in the reverse direction:

  • ERC20LockedERC1155 - you can swap (and swap back) any ERC-1155 token to your ERC-20 token.
  • ERC20OverERC1155 - you give pemission to this contract transfer a ERC-1155 token as if it were a ERC-20 token, that is when you transfer this ERC-20, the ERC-1155 is transferred too, and vice versa. Non-fixable bug: This ERC-20 does not emit events on transfers (because we can't emit every event the standard requires, as it would involve emitting an event for every token holder on the net when you initialize it, what is clearly impossible).

It is your choice whether to use *Locked* or *Over* tokens: *Over* are easier to use and spend less gas, but they have a bug (see above). Note that this bug does not matter for our science and free software donations and bequest system.

Finally, as said above for every of the above contracts, we have also the four corresponding SmartWalletWith* contracts, that you can use to both bequest your funds and keep using them for DeFi and other contract calls.

Installation

yarn
npx hardhat compile
yarn export
npx hardhat deploy --network ...

Testing

yarn
npx hardhat test

You can create new ERC-20 tokens for testing by a command like:

ACCOUNT=0x... npx hardhat run scripts/mint-erc20.js --network ganache

Contract addresses

Binance Smart Chain

ERC1155LockedERC20 0x23AdBf93Cb8D21bc9E9a0bAd75eE8326d5C04D86

ERC1155OverERC20 0x0D3e93CeeB31760EbB38e18DA61ECA10a948BA9f

Binance Smart Chain Testnet

ERC1155LockedERC20 0xBab0Fb354c9100EE7D549B0Db5E0697dE45947BC

ERC1155OverERC20 0x54a24917f410505d70E328b5399e42E8a935F48f

Mainnet

TODO