Skip to content

Commit 219c4c2

Browse files
authored
add SimpleContract example to hardhat-plugin example (#4)
1 parent c364c65 commit 219c4c2

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

examples/hardhat-plugin/README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ The project is configured in `hardhat.config.ts` to use the Silent Data Rollup n
3333
}
3434
```
3535

36-
## Smart Contract
36+
## Smart Contracts
3737

3838
The example includes a simple `PrivateToken.sol` contract that implements a privacy-focused ERC20 token with the following features:
3939

4040
- Implements the ERC20 standard interface
4141
- Only allows token holders to view their own balance through the `balanceOf` method
4242

43-
## Deployment
43+
These is also a very basic contract example called `SimpleContract`.
44+
45+
## Deployment - PrivateToken
4446

4547
The project uses Hardhat Ignition for deployments. The deployment module is configured in `ignition/modules/PrivateToken.ts`.
4648

@@ -52,14 +54,31 @@ npm run deploy
5254

5355
This will:
5456

55-
1. Compile the contract
57+
1. Compile the PrivateToken contract
58+
2. Deploy it to the Silent Data [Rollup] network
59+
60+
## Deployment - SimpleContract
61+
62+
The project uses Hardhat Ignition for deployments. The deployment module is configured in `ignition/modules/SimpleContract.ts`.
63+
64+
To deploy the contract:
65+
66+
```bash
67+
npm run deploy:simple-contract
68+
```
69+
70+
This will:
71+
72+
1. Compile the SimpleContract contract
5673
2. Deploy it to the Silent Data [Rollup] network
5774

5875
## Development
5976

6077
### Available Scripts
6178

79+
- `npm run compile` - Compile all contracts
6280
- `npm run deploy` - Deploy the PrivateToken contract using Hardhat Ignition
81+
- `npm run deploy:simple-contract` - Deploy the SimpleContract contract using Hardhat Ignition
6382

6483
### Project Dependencies
6584

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.20;
3+
4+
contract SimpleContract {
5+
uint256 public constant MY_CONSTANT = 42;
6+
7+
function getConstant() public pure returns (uint256) {
8+
return MY_CONSTANT;
9+
}
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { buildModule } from '@nomicfoundation/hardhat-ignition/modules'
2+
3+
const SimpleContract = buildModule('SimpleContract', (m) => {
4+
const simpleContract = m.contract('SimpleContract')
5+
6+
return { simpleContract }
7+
})
8+
9+
export default SimpleContract

examples/hardhat-plugin/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"name": "example-hardhat-plugin",
33
"scripts": {
4-
"deploy": "npx hardhat compile && npx hardhat ignition deploy ignition/modules/PrivateToken.ts"
4+
"compile": "npx hardhat compile",
5+
"deploy": "npx hardhat compile && npx hardhat ignition deploy ignition/modules/PrivateToken.ts",
6+
"deploy:simple-contract": "npx hardhat compile && npx hardhat ignition deploy ignition/modules/SimpleContract.ts"
57
},
68
"devDependencies": {
79
"@appliedblockchain/silentdatarollup-hardhat-plugin": "file:../../packages/hardhat-plugin",

0 commit comments

Comments
 (0)