Skip to content

Commit

Permalink
Initial setup (#2)
Browse files Browse the repository at this point in the history
* update deps

* first version

* add netspec comments

* comment evmVersion

* update versions

* add tests

* readme update
  • Loading branch information
julienbrg authored Sep 18, 2024
1 parent 8889d64 commit f374729
Show file tree
Hide file tree
Showing 8 changed files with 788 additions and 1,001 deletions.
49 changes: 13 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
# W3HC Hardhat Template
# Enki

This Hardhat template includes:
On-chain tool for collaborative text editing.

- [Typescript](https://www.typescriptlang.org/)
- [Ethers v6](https://docs.ethers.org/v6/)
- [OpenZeppelin Contracts v5.0.1](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.1)
- [Hardhat Verify plugin](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify)
- [Hardhat Deploy plugin](https://github.com/wighawag/hardhat-deploy)

## Supported networks

- [Arthera Mainnet](https://chainlist.org/chain/10242) ([docs](https://docs.arthera.net/build/networks#arthera-mainnet))
- [Arthera testnet](https://chainlist.org/chain/10243) ([docs](https://docs.arthera.net/build/networks#arthera-testnet))
- [Sepolia Testnet](https://chainlist.org/chain/11155111) ([docs](https://ethereum.org/nb/developers/docs/networks/#sepolia))
- [OP Sepolia Testnet](https://chainlist.org/chain/11155420) ([docs](https://docs.optimism.io/chain/networks#op-sepolia))
The contract owner should be a DAO (i.e. a [Gov contract](https://github.com/w3hc/gov)) so that any modification in the text is voted by the DAO members.

## Install

```
pnpm install
pnpm i
```

Create a `.env` file:
## Test

```
cp .env.template .env
pnpm test
```

Add your own keys in the `.env` file.
## Deploy

## Test
Create a `.env` file:

```
pnpm test
cp .env.template .env
```

## Deploy
Add your own keys in the `.env` file.

```
pnpm deploy:<NETWORK_NAME>
Expand All @@ -55,26 +44,14 @@ pnpm bal <NETWORK_NAME>
pnpm sourcify:<NETWORK_NAME>
```

## Mint

```
pnpm mint:<NETWORK_NAME> 42
```

## Send

```
pnpm send:<NETWORK_NAME> 8
```

## Versions

- Node [v20.9.0](https://nodejs.org/uk/blog/release/v20.9.0/)
- PNPM [v8.7.5](https://pnpm.io/pnpm-vs-npm)
- Hardhat [v2.19.4](https://github.com/NomicFoundation/hardhat/releases/)
- Hardhat [v2.22.10](https://github.com/NomicFoundation/hardhat/releases/)
- OpenZeppelin Contracts [v5.0.1](https://github.com/OpenZeppelin/openzeppelin-contracts/releases/tag/v5.0.1)
- Ethers [v6.10.0](https://docs.ethers.org/v6/)
- Ethers [v6.13.2](https://docs.ethers.org/v6/)

## Support

You can contact me via [Element](https://matrix.to/#/@julienbrg:matrix.org), [Telegram](https://t.me/julienbrg), [Twitter](https://twitter.com/julienbrg), [Discord](https://discordapp.com/users/julienbrg), or [LinkedIn](https://www.linkedin.com/in/julienberanger/).
You can contact me via [Element](https://matrix.to/#/@julienbrg:matrix.org), [Farcaster](https://warpcast.com/julien-), [Telegram](https://t.me/julienbrg), [Twitter](https://twitter.com/julienbrg), [Discord](https://discordapp.com/users/julienbrg), or [LinkedIn](https://www.linkedin.com/in/julienberanger/).
14 changes: 0 additions & 14 deletions contracts/Basic.sol

This file was deleted.

58 changes: 58 additions & 0 deletions contracts/Enki.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import "@openzeppelin/contracts/access/Ownable.sol";

/// @title Enki Contract
/// @author Julien Béranger
/// @notice This contract manages text and CID storage with owner-only write access
/// @dev Inherits from OpenZeppelin's Ownable contract for access control
contract Enki is Ownable {
/// @notice Emitted when the text and CID are updated
/// @param newText New text that was stored
/// @param newCID New CID that was stored
event Updated(string indexed newText, string indexed newCID);

/// @notice Stores the main text contents
string public text;

/// @notice Stores the Content Identifier (CID)
string public cid;

/// @notice Initializes the contract with an owner, initial text, and CID
/// @dev The initial owner should be a Governor contract address
/// @param initialOwner Address of the initial owner (Governor contract)
/// @param _text Initial text to be stored
/// @param _cid Initial CID to be stored
constructor(
address initialOwner,
string memory _text,
string memory _cid
) Ownable(initialOwner) {
text = _text;
cid = _cid;
}

/// @notice Retrieves the current stored text
/// @return The current value of the text variable
function read() public view returns (string memory) {
return text;
}

/// @notice Updates the stored text and CID
/// @dev Only the contract owner can call this function
/// @param _newText New text to be stored
/// @param _newCID New CID to be stored
function write(string calldata _newText, string calldata _newCID) public onlyOwner {
text = _newText;
cid = _newCID;
emit Updated(_newText, _newCID);
}

/// @notice Verifies if the provided text matches the stored text
/// @param _text Text to compare against the stored text
/// @return Boolean indicating whether the provided text matches the stored text
function verify(string calldata _text) public view returns (bool) {
return keccak256(abi.encodePacked(text)) == keccak256(abi.encodePacked(_text));
}
}
4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ const config: HardhatUserConfig = {
optimizer: {
enabled: true,
runs: 200
},
evmVersion: "shanghai"
}
// evmVersion: "shanghai"
}
},
etherscan: {
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,33 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomicfoundation/hardhat-network-helpers": "^1.0.10",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
"@nomicfoundation/hardhat-ethers": "^3.0.8",
"@nomicfoundation/hardhat-network-helpers": "^1.0.11",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@nomicfoundation/hardhat-verify": "^1.1.1",
"@typechain/ethers-v6": "^0.4.3",
"@typechain/hardhat": "^8.0.3",
"@types/chai": "^4.3.11",
"@types/chai": "^4.3.19",
"@types/cli-color": "^2.0.6",
"@types/mocha": "^10.0.6",
"chai": "^4.4.1",
"hardhat": "^2.19.4",
"hardhat-gas-reporter": "^1.0.9",
"@types/mocha": "^10.0.8",
"chai": "^4.5.0",
"hardhat": "^2.22.10",
"hardhat-deploy": "^0.12.4",
"hardhat-gas-reporter": "^1.0.10",
"prettier": "^2.8.8",
"prettier-plugin-solidity": "^1.3.1",
"solidity-coverage": "^0.8.6",
"prettier-plugin-solidity": "^1.4.1",
"solidity-coverage": "^0.8.13",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typescript": "^5.3.3"
"typescript": "^5.6.2"
},
"dependencies": {
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.4.1",
"@openzeppelin/contracts": "^5.0.1",
"@types/node": "^20.11.10",
"cli-color": "^2.0.3",
"dotenv": "^16.4.1",
"ethers": "^6.10.0",
"hardhat-deploy": "^0.11.45"
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.4.2",
"@openzeppelin/contracts": "^5.0.2",
"@types/node": "^20.16.5",
"cli-color": "^2.0.4",
"dotenv": "^16.4.5",
"ethers": "^6.13.2"
}
}
Loading

0 comments on commit f374729

Please sign in to comment.