Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tablelandnetwork/hardhat-ts-tableland-template
https://github.com/tablelandnetwork/hardhat-ts-tableland-template
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tablelandnetwork/hardhat-ts-tableland-template
- Owner: tablelandnetwork
- Created: 2023-05-30T20:55:08.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-08T20:26:34.000Z (8 months ago)
- Last Synced: 2024-05-08T21:35:55.634Z (8 months ago)
- Language: TypeScript
- Size: 463 KB
- Stars: 2
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tableland Hardhat TypeScript Template
> Hardhat TypeScript starter template for @tableland applications
## Table of Contents
- [Table of Contents](#table-of-contents)
- [Background](#background)
- [Usage](#usage)
- [Build \& deploy](#build--deploy)
- [Testing](#testing)
- [Formatting \& cleanup](#formatting--cleanup)
- [Extracting the ABI and bytecode](#extracting-the-abi-and-bytecode)
- [Contract verification](#contract-verification)
- [Contributing](#contributing)
- [License](#license)## Background
This repo contains starter code for building [`@tableland`](https://github.com/tablelandnetwork) applications. It comes packed with packages and starter code, including:
- Tableland clients & tools—EVM contracts, SDK, Local Tableland, and Hardhat Tableland plugin.
- A `Starter` contract that imports Tableland and OpenZeppelin contract—including table creation, writes, and access control setup.
- Basic deployment script and a unit test that sets up the `TablelandTables` registry for contract interaction.
- Other useful scripts and packages for local deployment, formatting, and testing—including `prettier`, `eslint`, `solhint`, and Hardhat configuration setup.## Usage
First, clone this repo:
```sh
git clone https://github.com/tablelandnetwork/hardhat-ts-tableland-template
```### Build & deploy
To simply compile contracts, you can install dependencies with `npm install` and then run:
```
npm run build
```To install packages, compile contracts, and also startup Local Tableland and Hardhat nodes, run the following:
```
npm run up
```This will keep the nodes running until you exit the session. While this is running, you can then choose to deploy the contracts to these local networks by opening a new terminal window and running:
```
npm run deploy:up
```Alternatively, you may want to deploy contracts locally but without active nodes running. The following can be used to deploy the contracts while also starting & shutting down Local Tableland and Hardhat nodes once the script exits. Be sure anything running via `npm run up` has been closed out before running:
```
npm run deploy:local
```Lastly, to deploy to any live network listed in `hardhat.config.ts`, you can simply pass the network name after running the `deploy` command. The `.env.example` file should first be copied to a `.env` file and then have all of the values for private keys and API keys replaced. For example, to deploy contracts on Ethereum mainnet, you would do the following after creating a `.env` file with variables for `ETHEREUM_PRIVATE_KEY`, `ETHEREUM_API_KEY`, and (optionally) `ETHERSCAN_API_KEY`:
```
npm run deploy mainnet
```Note that if no network name is passed, the script will fail.
### Testing
For full test coverage, run the following, which will show statement, branch, function, and line coverage (see `index.html` located in the `coverage` directory):
```
npm test
```You can see gas costs associated with each contract method:
```
npm run test:gas
```### Formatting & cleanup
Remove untracked files and directories, such as those that were autogenerated:
```
npm run clean
```Format and lint the project:
```
npm run format
```### Extracting the ABI and bytecode
You can grab the assets you need by compiling the contracts and then using some [`jq`](https://jqlang.github.io/jq/) magic:
#### ABI
```shell
cat artifacts/contracts/Starter.sol/Starter.json | jq '.abi' > abi.json
```#### Bytecode
```shell
cat artifacts/contracts/Starter.sol/Starter.json | jq -r '.bytecode' > bytecode.bin
```### Contract verification
To perform contract verification on Etherscan and other block explorers, you first need to deploy a contract to a live network, such as Sepolia:
```shell
npx hardhat run scripts/deploy.ts --network sepolia
```Then, copy the logged deployment address and replace `DEPLOYED_CONTRACT_ADDRESS` with this value in the command below:
```shell
npx hardhat verify DEPLOYED_CONTRACT_ADDRESS --network sepolia
```## Contributing
PRs accepted.
Small note: If editing the README, please conform to the
[standard-readme](https://github.com/RichardLitt/standard-readme) specification.## License
MIT AND Apache-2.0, © 2021-2023 Tableland Network Contributors