-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add hardhat scripts for contract and user interactions Signed-off-by: nikolay <[email protected]> * Add readme Signed-off-by: nikolay <[email protected]> * Fix code smells Signed-off-by: nikolay <[email protected]> * Add relay endpoint url in .env Signed-off-by: nikolay <[email protected]> * Uncomment tests Signed-off-by: nikolay <[email protected]> * Add license headers Signed-off-by: nikolay <[email protected]>
- Loading branch information
Showing
13 changed files
with
34,632 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
OPERATOR_PRIVATE_KEY= | ||
RECEIVER_PRIVATE_KEY= | ||
RELAY_ENDPOINT='http://localhost:7546' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
node_modules | ||
.env | ||
coverage | ||
coverage.json | ||
typechain | ||
typechain-types | ||
|
||
#Hardhat files | ||
cache | ||
artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Hardhat example | ||
|
||
Simple scripts for basic operations like hbars transfer, balance fetching, and contract interactions (deployment and calls). | ||
|
||
## Prerequisite | ||
You must have running: | ||
- JSON-RPC Relay | ||
|
||
## Configuration | ||
|
||
Create `.env` file based on `.env.example` | ||
``` | ||
# Alias accounts keys | ||
OPERATOR_PRIVATE_KEY= | ||
RECEIVER_PRIVATE_KEY= | ||
``` | ||
|
||
## Setup & Install | ||
|
||
In the project directory: | ||
|
||
1. Run `npm install` | ||
2. Run `npx hardhat test` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//SPDX-License-Identifier: Unlicense | ||
pragma solidity ^0.8.0; | ||
|
||
contract Greeter { | ||
string private greeting; | ||
|
||
constructor(string memory _greeting) { | ||
greeting = _greeting; | ||
} | ||
|
||
function greet() public view returns (string memory) { | ||
return greeting; | ||
} | ||
|
||
function setGreeting(string memory _greeting) public { | ||
greeting = _greeting; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/*- | ||
* | ||
* Hedera JSON RPC Relay - Hardhat Example | ||
* | ||
* Copyright (C) 2022 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
require('dotenv').config(); | ||
require('@nomicfoundation/hardhat-toolbox'); | ||
|
||
task('show-balance', async () => { | ||
const showBalance = require('./scripts/showBalance'); | ||
return showBalance(); | ||
}); | ||
|
||
task('transfer-hbars', async () => { | ||
const transferHbars = require('./scripts/transferHbars'); | ||
return transferHbars(); | ||
}); | ||
|
||
task('deploy-contract', async () => { | ||
const deployContract = require('./scripts/deployContract'); | ||
return deployContract(); | ||
}); | ||
|
||
task('contract-view-call', async (taskArgs) => { | ||
const contractViewCall = require('./scripts/contractViewCall'); | ||
return contractViewCall(taskArgs.contractAddress); | ||
}); | ||
|
||
task('contract-call', async (taskArgs) => { | ||
const contractCall = require('./scripts/contractCall'); | ||
return contractCall(taskArgs.contractAddress, taskArgs.msg); | ||
}); | ||
|
||
module.exports = { | ||
solidity: '0.8.4', | ||
defaultNetwork: 'relay', | ||
networks: { | ||
relay: { | ||
url: process.env.RELAY_ENDPOINT | ||
} | ||
} | ||
}; |
Oops, something went wrong.