Skip to content

Commit

Permalink
refactor README
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfuturistic committed Jun 11, 2024
1 parent a432c83 commit cfe8199
Showing 1 changed file with 23 additions and 51 deletions.
74 changes: 23 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,38 @@
## Foundry
# ✨ Transience

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
Transience is a Solidity library for safely managing transient storage in smart contracts. It stores values in a context-specific way (by call depth), preventing reentrancy attacks and ensuring secure and isolated storage across nested function calls.

Foundry consists of:
## Features

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
- **Transient Storage**: Transience offers methods for writing and reading transient storage without having to use assembly/Yul.

## Documentation
- **Reentrancy Awareness**: Transience keeps track of the current call depth, preventing a nested function call from overwriting the transient storage of the parent call (i.e., a reentrancy attack).

https://book.getfoundry.sh/
## How It Works

## Usage
Transience uses a unique slot identifier and the current call depth to determine a distinct storage location in transient storage.
The library provides two main functions:

### Build
- `get(bytes32 _slot)`: Retrieves the value in transient storage corresponding to `_slot` at the current call depth.
- `set(bytes32 _slot, uint256 _value)`: Sets `_value` as the value in transient storage corresponding to `_slot` at the current call depth.

```shell
$ forge build
```

### Test

```shell
$ forge test
```
The `TransientReentrancyAware` contract offers a `reentrantAware` modifier that automatically increments and decrements the call depth when entering and exiting a function, ensuring isolation from calls at other call depths (i.e., from a nested reentrant call).

### Format
## Getting Started

```shell
$ forge fmt
1. Install the library in your Solidity project
```bash
forge install ethereum-optimism/transience
```

### Gas Snapshots

```shell
$ forge snapshot
2. Import the library's contracts in your smart contract
```solidity
import {TransientContext, TransientReentrancyAware} from "transience/src/TransientContext.sol";
```
3. Inherit from `TransientReentrancyAware` to access the `reentrantAware` modifier
4. Optionally, use the `get()` and `set()` functions to store and retrieve values in the transient storage at arbitrary slots

### Anvil

```shell
$ anvil
```
## Contribute & Feedback

### Deploy
Feel free to raise an issue, suggest a feature, or even fork the repository for personal tweaks. If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are warmly welcome.

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```

### Cast

```shell
$ cast <subcommand>
```

### Help

```shell
$ forge --help
$ anvil --help
$ cast --help
```
For questions and feedback, you can also reach out via [Twitter](https://twitter.com/0xfuturistic).

0 comments on commit cfe8199

Please sign in to comment.