Skip to content

Commit

Permalink
feat/refactoring getting started with foundry to fix details and add …
Browse files Browse the repository at this point in the history
…--evm-version london to avid deploy error
  • Loading branch information
SebasGuaquetaRSK committed Oct 23, 2024
1 parent 0832209 commit dcece19
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ROOTSTOCK_RPC_URL=https://rpc.testnet.rootstock.io/{YOUR_APIKEY}
PRIVATE_KEY=0x...
```
:::info[Info]
* Your PRIVATE_KEY has to be formatted correctly, so it has to start with `0x`.
* To obtain a Rootstock Rpc Url, visit the [RPC API DASHBOARD](https://rpc.rootstock.io/), create an account and get your testnet or mainnet rpc url.
:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tags: [guides, developers, smart contracts, rsk, rootstock, foundry, dApps]
In this section, you'll deploy a `counter` smart contract to the Rootstock network using Foundry.

## Step 1: Deployment Script
You will see a directory called `deploy` in the root of your project. This is where you can view/write your deployment scripts. The demo `counter.sol` comes with a deployment script `counter.s.sol`, which contains:
You will see a directory called `deploy` in the root of your project. This is where you can view/write your deployment scripts. The demo `counter.sol` comes with a deployment script `counter.s.sol`, please copy the following code into the file:

```solidity
// SPDX-License-Identifier: UNLICENSED
Expand All @@ -30,15 +30,18 @@ contract CounterScript is Script {
}
}
```
:::info[Info]
- Demo comes with Foundry's default sender, in this script we are using the sender's private key to deploy the contract ```vm.envUint("PRIVATE_KEY")```.
:::
## Step 2: Deploy Your Contract on Rootstock Network
Run the following command, replacing `https://public-node.testnet.rsk.co` with either `rskTestnet` or `rskMainnet` rpc url if you have, depending on your desired deployment environment:

```bash
forge script script/Deploy.s.sol --rpc-url https://public-node.testnet.rsk.co --broadcast --legacy
forge script script/Counter.s.sol --rpc-url https://public-node.testnet.rsk.co --broadcast --legacy --evm-version london
```
:::info[Info]

- [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md) is not supported or not activated on the Rootstock RPC url
- To avoid Foundry's compatibility issues, we are using the `--evm-version london` flag.
- The `--legacy` flag is passed to use legacy transactions instead of `EIP-1559`.
- You can remove the `--broadcast` flag if you wan to simulate the transaction without broadcasting it.
:::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ $ tree . -d -L 1
4 directories
```

The `src` directory contains counter smart contract with test written in the `test` directory. Now, let's build the foundry project.

```bash
forge build
```

And then run tests.

```bash
forge test
```

## Demo smart contract
In the `src` folder, you will find a simple smart contract called `counter.sol`. Which contains a simple counter contract.

Expand Down

0 comments on commit dcece19

Please sign in to comment.