https://github.com/0age/rstore
RStore - use the runtime code of metamorphic contracts for dynamic storage.
https://github.com/0age/rstore
contract efficient ethereum metamorphic runtime smart-contracts solidity storage
Last synced: 10 months ago
JSON representation
RStore - use the runtime code of metamorphic contracts for dynamic storage.
- Host: GitHub
- URL: https://github.com/0age/rstore
- Owner: 0age
- License: mit
- Created: 2019-03-05T03:15:44.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-16T06:42:58.000Z (almost 3 years ago)
- Last Synced: 2025-04-13T09:46:47.870Z (12 months ago)
- Topics: contract, efficient, ethereum, metamorphic, runtime, smart-contracts, solidity, storage
- Language: JavaScript
- Size: 15.6 KB
- Stars: 19
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# RStore

[](https://travis-ci.org/0age/RStore)
[](https://github.com/RichardLitt/standard-readme)
[](http://makeapullrequest.com)
> RStore - use the runtime code of metamorphic contracts for dynamic storage.
This contract uses metamorphic contracts in place of standard storage in order to save gas for certain applications. Then, `extcodecopy` is used to retrieve values from the runtime code of a metamorphic contract, which can be redeployed after a selfdestruct in order to update storage. This is bleeding-edge stuff, so use at your own risk!
There are actually two different metamorphic contracts that are used in alternating order to support single-transaction storage updates. Each caller also has their own, independent associated metamorphic storage contracts. Gas usage can almost certainly be optimized further from here - this is meant to serve as a proof-of-concept of using contract runtime code for storage.
**DISCLAIMER: this implements a few highly experimental features - be sure to *educate the users of your contract* if it will rely on metamorphic contracts for storage! These contracts have not yet been fully tested or audited - proceed with caution and please share any exploits or optimizations you discover.**
For additional context and an explanation of the initialization code used to deploy metamorphic storage contracts, check out [this post](https://medium.com/@0age/on-efficient-ethereum-storage-c76869591add).
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Maintainers](#maintainers)
- [Contribute](#contribute)
- [License](#license)
## Install
To install locally, you'll need Node.js 10+ and Yarn *(or npm)*. To get everything set up:
```sh
$ git clone https://github.com/0age/RStore.git
$ cd RStore
$ yarn install
$ yarn build
```
## Usage
In a new terminal window, start the testRPC, run tests, and tear down the testRPC *(you can do all of this at once via* `yarn all` *if you prefer)*:
```sh
$ yarn start
$ yarn test
$ yarn linter
$ yarn analyze # this takes a while and is for calculating gas usage
$ yarn stop
```
## API
See the source code of the contracts for usage information. It's really quite simple - basically just `set(bytes calldata data)` and `get()`, plus some convenience view functions.
## Maintainers
[@0age](https://github.com/0age)
## Contribute
PRs accepted gladly - make sure the tests and linters pass.
## License
MIT © 2019 0age