Simple contract to store Ethereum Observer Summary
https://ethereum-observer-api.andromeda.technology
Simple Ethereum Smart Contract that stores a Daily Summary of Ethereum Observer API.
Use it as a scalable Smart Contract Development boilerplate and/or a learning resource.
- Contract, written in Solidity,
- Contract tests, TypeScript,
- Deployment script, TypeScript,
- Accounts task, TypeScript.
- Method:
addSummary(dayId, blocks, gas),- available to contract creator only,
- reverts the state and returns
WriteAccessForbidenError if not run by the contract creator, - raises
SummaryAddedEvent otherwise,
- Method:
getSummary(dayId)- available to anyone,
- Method:
getCreator()- returns contract creator address.
- Hardhat - Ethereum development environment for professionals,
- TypeScript - to level-up Hardhat environment robustness while writing tests and scripts (e.g. deployment),
- Solidity - Smart Contract development language,
- Ethers.js - communication with Ethereum (e.g. accounts, deployment, testing, ...),
- Waffle - contract testing library.
- Duplicate
.env.exampleto.env. - Enter your Etherscan API key (to verify deployment status of your contract),
- Enter your Ropsten node URL (eg from Alchemy) (Hardhat will send transactions to this Ethereum node),
- Enter the private key of the account which will send the deployment transaction, and of the guest account (used for testing).
- Set
PRIVATE_KEY- creator of the Contract, - Set
PRIVATE_KEY_GUEST- used to test access rights to Contract methods.
Note: Private keys can be obtained by creating two (2) accounts in MetaMask (e.g. in different browsers).
Run npx hardhat test.
Contract NetworkSummary:
- Sets the proper creator address,
- Forbids write access to non-creator,
- Stores summary for the day and returns it.
With a valid .env file in place, to deploy your contract run:
npx hardhat run --network ropsten scripts/deploy.tsThen, copy the deployment address and paste it in to replace DEPLOYED_CONTRACT_ADDRESS in the verification section (check 6.1.).
To try out Etherscan verification, you first need to deploy a contract to an Ethereum network that's supported by Etherscan, such as Ropsten (check 6.).
npx hardhat verify --network ropsten DEPLOYED_CONTRACT_ADDRESS "Hello, Hardhat!"Previous sections covered most of the commands you should try out, to get up and running quickly and get a sense of what is going on.
If you wish to dive deeper, check out the available tasks:
npx hardhat accounts # built-in Hardhat network accounts
npx hardhat --network [name] accounts # [name]: e.g. `ropsten`
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
npx hardhat help
REPORT_GAS=true npx hardhat test
npx hardhat coverage
npx hardhat run scripts/deploy.ts
TS_NODE_FILES=true npx ts-node scripts/deploy.ts
npx eslint '**/*.{js,ts}'
npx eslint '**/*.{js,ts}' --fix
npx prettier '**/*.{json,sol,md}' --check
npx prettier '**/*.{json,sol,md}' --write
npx solhint 'contracts/**/*.sol'
npx solhint 'contracts/**/*.sol' --fixFor faster runs of your tests and scripts, consider skipping ts-node's type checking by setting the environment variable TS_NODE_TRANSPILE_ONLY to 1 in hardhat's environment.
For more details see the documentation.
Andromeda
Hero image source: Hardhat.org.
๐ญ Ethereum Observer API - Simple tracker for Ethereum Network
- Simple block and transaction tracker for Ethereum network,
- TypeScript,
- Koa.js,
- MongoDB,
- Jest,
- Docker.
๐ FireStarter API - Progressive Startup API Boilerplate
- Easy to extend, Progressive and Scalable API boilerplate to power your startup,
- TypeScript,
- Koa.js,
- MongoDB,
- Jest,
- Docker.
๐ Habitus - Journal, Habit, Emotion tracker
- State-of-the-art tracker for emotions, habits and thoughts,
- Healthiest version of you,
- Gamified,
- Anonymous and open source.
- TypeScript, Koa.js, Vue.js, MongoDB, Jest.
Check Self-Aware Software Artisan before contributing.