├── .DS_Store
├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── SECURITY.md
├── foundry
└── erc20
│ ├── .env.example
│ ├── .gitattributes
│ ├── .gitignore
│ ├── .vscode
│ └── settings.json
│ ├── LICENSE
│ ├── README.md
│ ├── foundry.toml
│ ├── remappings.txt
│ ├── script
│ └── Acacia.s.sol
│ └── src
│ └── Acacia.sol
├── hardhat
├── .DS_Store
├── deterministic-deployer-example
│ ├── .env.example
│ ├── .gitignore
│ ├── .prettierrc
│ ├── LICENSE
│ ├── README.md
│ ├── contracts
│ │ └── TestToken.sol
│ ├── hardhat.config.ts
│ ├── package.json
│ ├── scripts
│ │ └── deploy.ts
│ ├── src
│ │ └── Deterministic-Deployer.ts
│ └── tsconfig.json
├── erc20
│ ├── .DS_Store
│ ├── .env.sample
│ ├── .gitignore
│ ├── Makefile
│ ├── README.md
│ ├── contracts
│ │ └── WatermelonToken.sol
│ ├── hardhat.config.js
│ ├── package-lock.json
│ ├── package.json
│ ├── scripts
│ │ └── deploy.js
│ ├── tasks
│ │ ├── account.js
│ │ ├── approve.js
│ │ ├── balanceOf.js
│ │ ├── totalSupply.js
│ │ ├── transfer.js
│ │ └── transferFrom.js
│ └── yarn.lock
├── greeter-example
│ ├── .DS_Store
│ ├── .env.sample
│ ├── .gitignore
│ ├── Makefile
│ ├── README.md
│ ├── contracts
│ │ └── Greeter.sol
│ ├── hardhat.config.js
│ ├── package-lock.json
│ ├── package.json
│ ├── scripts
│ │ └── deploy.js
│ ├── test
│ │ └── sample.test.js
│ └── yarn.lock
└── incrementer-example
│ ├── .DS_Store
│ ├── .env.sample
│ ├── .gitignore
│ ├── Makefile
│ ├── README.md
│ ├── contracts
│ └── Incrementer.sol
│ ├── hardhat.config.js
│ ├── package.json
│ ├── scripts
│ ├── deploy.js
│ └── utils.js
│ └── yarn.lock
└── truffle
├── .DS_Store
├── README.md
├── erc721-example
├── .DS_Store
├── .env.sample
├── .gitignore
├── README.md
├── contracts
│ ├── CovidVaccineToken.sol
│ └── Migrations.sol
├── images
│ └── truffle_nft_example.png
├── migrations
│ ├── 1_initial_migration.js
│ └── 2_deploy_contracts.js
├── package.json
├── test
│ └── .gitkeep
├── truffle-config.js
└── yarn.lock
└── pet-shop-example
├── .DS_Store
├── .env.sample
├── LICENSE
├── README.md
├── box-img-lg.png
├── box-img-sm.png
├── bs-config.json
├── contracts
├── Adoption.sol
└── Migrations.sol
├── migrations
├── 1_initial_migration.js
└── 2_deploy_contracts.js
├── package.json
├── scripts
└── deploy.js
├── src
├── css
│ ├── bootstrap.min.css
│ └── bootstrap.min.css.map
├── fonts
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.svg
│ ├── glyphicons-halflings-regular.ttf
│ ├── glyphicons-halflings-regular.woff
│ └── glyphicons-halflings-regular.woff2
├── images
│ ├── boxer.jpeg
│ ├── french-bulldog.jpeg
│ ├── golden-retriever.jpeg
│ └── scottish-terrier.jpeg
├── index.html
├── js
│ ├── app.js
│ ├── bootstrap.min.js
│ ├── truffle-contract.js
│ └── web3.min.js
└── pets.json
├── test
└── TestAdoption.sol
├── truffle.js
└── yarn.lock
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitfinity-network/bitfinity-evm-examples/91de96ea859d62d9db494691ad4a5f0c4d49d791/.DS_Store
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "foundry/erc20/lib/forge-std"]
2 | path = foundry/erc20/lib/forge-std
3 | url = https://github.com/foundry-rs/forge-std
4 | [submodule "foundry/erc20/lib/openzeppelin-contracts"]
5 | path = foundry/erc20/lib/openzeppelin-contracts
6 | url = https://github.com/OpenZeppelin/openzeppelin-contracts
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | CC0 1.0 Universal
2 |
3 | Statement of Purpose
4 |
5 | The laws of most jurisdictions throughout the world automatically confer
6 | exclusive Copyright and Related Rights (defined below) upon the creator and
7 | subsequent owner(s) (each and all, an "owner") of an original work of
8 | authorship and/or a database (each, a "Work").
9 |
10 | Certain owners wish to permanently relinquish those rights to a Work for the
11 | purpose of contributing to a commons of creative, cultural and scientific
12 | works ("Commons") that the public can reliably and without fear of later
13 | claims of infringement build upon, modify, incorporate in other works, reuse
14 | and redistribute as freely as possible in any form whatsoever and for any
15 | purposes, including without limitation commercial purposes. These owners may
16 | contribute to the Commons to promote the ideal of a free culture and the
17 | further production of creative, cultural and scientific works, or to gain
18 | reputation or greater distribution for their Work in part through the use and
19 | efforts of others.
20 |
21 | For these and/or other purposes and motivations, and without any expectation
22 | of additional consideration or compensation, the person associating CC0 with a
23 | Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25 | and publicly distribute the Work under its terms, with knowledge of his or her
26 | Copyright and Related Rights in the Work and the meaning and intended legal
27 | effect of CC0 on those rights.
28 |
29 | 1. Copyright and Related Rights. A Work made available under CC0 may be
30 | protected by copyright and related or neighboring rights ("Copyright and
31 | Related Rights"). Copyright and Related Rights include, but are not limited
32 | to, the following:
33 |
34 | i. the right to reproduce, adapt, distribute, perform, display, communicate,
35 | and translate a Work;
36 |
37 | ii. moral rights retained by the original author(s) and/or performer(s);
38 |
39 | iii. publicity and privacy rights pertaining to a person's image or likeness
40 | depicted in a Work;
41 |
42 | iv. rights protecting against unfair competition in regards to a Work,
43 | subject to the limitations in paragraph 4(a), below;
44 |
45 | v. rights protecting the extraction, dissemination, use and reuse of data in
46 | a Work;
47 |
48 | vi. database rights (such as those arising under Directive 96/9/EC of the
49 | European Parliament and of the Council of 11 March 1996 on the legal
50 | protection of databases, and under any national implementation thereof,
51 | including any amended or successor version of such directive); and
52 |
53 | vii. other similar, equivalent or corresponding rights throughout the world
54 | based on applicable law or treaty, and any national implementations thereof.
55 |
56 | 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58 | unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59 | and Related Rights and associated claims and causes of action, whether now
60 | known or unknown (including existing as well as future claims and causes of
61 | action), in the Work (i) in all territories worldwide, (ii) for the maximum
62 | duration provided by applicable law or treaty (including future time
63 | extensions), (iii) in any current or future medium and for any number of
64 | copies, and (iv) for any purpose whatsoever, including without limitation
65 | commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66 | the Waiver for the benefit of each member of the public at large and to the
67 | detriment of Affirmer's heirs and successors, fully intending that such Waiver
68 | shall not be subject to revocation, rescission, cancellation, termination, or
69 | any other legal or equitable action to disrupt the quiet enjoyment of the Work
70 | by the public as contemplated by Affirmer's express Statement of Purpose.
71 |
72 | 3. Public License Fallback. Should any part of the Waiver for any reason be
73 | judged legally invalid or ineffective under applicable law, then the Waiver
74 | shall be preserved to the maximum extent permitted taking into account
75 | Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76 | is so judged Affirmer hereby grants to each affected person a royalty-free,
77 | non transferable, non sublicensable, non exclusive, irrevocable and
78 | unconditional license to exercise Affirmer's Copyright and Related Rights in
79 | the Work (i) in all territories worldwide, (ii) for the maximum duration
80 | provided by applicable law or treaty (including future time extensions), (iii)
81 | in any current or future medium and for any number of copies, and (iv) for any
82 | purpose whatsoever, including without limitation commercial, advertising or
83 | promotional purposes (the "License"). The License shall be deemed effective as
84 | of the date CC0 was applied by Affirmer to the Work. Should any part of the
85 | License for any reason be judged legally invalid or ineffective under
86 | applicable law, such partial invalidity or ineffectiveness shall not
87 | invalidate the remainder of the License, and in such case Affirmer hereby
88 | affirms that he or she will not (i) exercise any of his or her remaining
89 | Copyright and Related Rights in the Work or (ii) assert any associated claims
90 | and causes of action with respect to the Work, in either case contrary to
91 | Affirmer's express Statement of Purpose.
92 |
93 | 4. Limitations and Disclaimers.
94 |
95 | a. No trademark or patent rights held by Affirmer are waived, abandoned,
96 | surrendered, licensed or otherwise affected by this document.
97 |
98 | b. Affirmer offers the Work as-is and makes no representations or warranties
99 | of any kind concerning the Work, express, implied, statutory or otherwise,
100 | including without limitation warranties of title, merchantability, fitness
101 | for a particular purpose, non infringement, or the absence of latent or
102 | other defects, accuracy, or the present or absence of errors, whether or not
103 | discoverable, all to the greatest extent permissible under applicable law.
104 |
105 | c. Affirmer disclaims responsibility for clearing rights of other persons
106 | that may apply to the Work or any use thereof, including without limitation
107 | any person's Copyright and Related Rights in the Work. Further, Affirmer
108 | disclaims responsibility for obtaining any necessary consents, permissions
109 | or other rights required for any use of the Work.
110 |
111 | d. Affirmer understands and acknowledges that Creative Commons is not a
112 | party to this document and has no duty or obligation with respect to this
113 | CC0 or use of the Work.
114 |
115 | For more information, please see
116 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Bitfinity-Examples
2 |
3 | This repository includes DApp boilerplates for [truffle](https://www.trufflesuite.com/), [hardhat](https://hardhat.org/) and [Foundry] () on Bitfinity. These examples cover specific topics:
4 |
5 | - Solidity contract deployment using (Truffle/Hardhat/Foundry).
6 | - Integration with Metamask
7 | - Running DApp on Bitfinity network
8 |
9 | ## Prerequisites
10 |
11 | - Node 12+
12 |
13 | ## Examples
14 |
15 | - [Truffle](truffle/)
16 | - [Hardhat](hardhat/)
17 | - [Foundry](foundry/)
18 |
19 | More documentation about Bitfinity network can be found [here](https://docs.bitfinity.network/).
20 |
21 | ## Contributing
22 |
23 | Bitfinity team welcomes any kind of contributions in form of bug issues, feature requests, code changes, or documentation enhancement.
24 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | Use this section to tell people about which versions of your project are
6 | currently being supported with security updates.
7 |
8 | | Version | Supported |
9 | | ------- | ------------------ |
10 | | 5.1.x | :white_check_mark: |
11 | | 5.0.x | :x: |
12 | | 4.0.x | :white_check_mark: |
13 | | < 4.0 | :x: |
14 |
15 | ## Reporting a Vulnerability
16 |
17 | Use this section to tell people how to report a vulnerability.
18 |
19 | Tell them where to go, how often they can expect to get an update on a
20 | reported vulnerability, what to expect if the vulnerability is accepted or
21 | declined, etc.
22 |
--------------------------------------------------------------------------------
/foundry/erc20/.env.example:
--------------------------------------------------------------------------------
1 | MNEMONIC="YOUR_MNEMONIC"
2 | FOUNDRY_PROFILE="default"
3 | PRIVATE_KEY=
4 | BITFINITY_RPC_URL="https://testnet.bitfinity.network"
5 |
--------------------------------------------------------------------------------
/foundry/erc20/.gitattributes:
--------------------------------------------------------------------------------
1 | .gas-snapshot linguist-language=Julia
2 |
--------------------------------------------------------------------------------
/foundry/erc20/.gitignore:
--------------------------------------------------------------------------------
1 | /cache
2 | /node_modules
3 | /out
--------------------------------------------------------------------------------
/foundry/erc20/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "solidity.packageDefaultDependenciesContractsDirectory": "src",
3 | "solidity.packageDefaultDependenciesDirectory": "lib",
4 | "solidity.compileUsingRemoteVersion": "v0.8.20",
5 | "solidity.formatter": "forge",
6 | "search.exclude": { "lib": true },
7 | "files.associations": {
8 | ".gas-snapshot": "julia"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/foundry/erc20/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Bitfinity Network
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/foundry/erc20/README.md:
--------------------------------------------------------------------------------
1 | # Foundry
2 |
3 | A Foundry-based ERC20 token deployment.
4 |
5 | ## What's Inside
6 |
7 | - [Forge](https://github.com/foundry-rs/foundry/blob/master/forge): compile, test, fuzz, format, and deploy smart
8 | contracts
9 | - [Forge Std](https://github.com/foundry-rs/forge-std): collection of helpful contracts and cheatcodes for testing
10 |
11 | If this is your first time with Foundry, check out the
12 | [installation](https://github.com/foundry-rs/foundry#installation) instructions.
13 |
14 | ## Features
15 |
16 | This template builds upon the frameworks and libraries mentioned above, so for details about their specific features,
17 | please consult their respective documentation.
18 |
19 | For example, if you're interested in exploring Foundry in more detail, you should look at the
20 | [Foundry Book](https://book.getfoundry.sh/). In particular, you may be interested in reading the
21 | [Writing Tests](https://book.getfoundry.sh/forge/writing-tests.html) tutorial.
22 |
23 | ### Sensible Defaults
24 |
25 | This template comes with a set of sensible default configurations for you to use. These defaults can be found in the
26 | following files:
27 |
28 | ```text
29 | ├── .gitignore
30 | ├── .solhint.json
31 | ├── foundry.toml
32 | └── remappings.txt
33 | ```
34 |
35 | ### VSCode Integration
36 |
37 | This template is IDE agnostic, but for the best user experience, you may want to use it in VSCode alongside Nomic
38 | Foundation's [Solidity extension](https://marketplace.visualstudio.com/items?itemName=NomicFoundation.hardhat-solidity).
39 |
40 | For guidance on how to integrate a Foundry project in VSCode, please refer to this
41 | [guide](https://book.getfoundry.sh/config/vscode).
42 |
43 | ## Usage
44 |
45 | This is a list of the most frequently needed commands.
46 |
47 | ### Build
48 |
49 | Build the contracts:
50 |
51 | ```sh
52 | forge build
53 | ```
54 |
55 | ### Clean
56 |
57 | Delete the build artifacts and cache directories:
58 |
59 | ```sh
60 | forge clean
61 | ```
62 |
63 | ### Compile
64 |
65 | Compile the contracts:
66 |
67 | ```sh
68 | forge build
69 | ```
70 |
71 | ### Coverage
72 |
73 | Get a test coverage report:
74 |
75 | ```sh
76 | forge coverage
77 | ```
78 |
79 | ### Deploy
80 |
81 | Deploy to Bitfinity testnet :
82 |
83 | ```sh
84 | # To load the variables in the .env file
85 | source .env
86 | forge script script/NFT.s.sol:MyScript --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv
87 | ```
88 |
89 | For this script to work, you need to have a `MNEMONIC` environment variable set to a valid
90 | [BIP39 mnemonic](https://iancoleman.io/bip39/).
91 |
92 | For instructions on how to deploy to a testnet or mainnet, check out the
93 | [Solidity Scripting](https://book.getfoundry.sh/tutorials/solidity-scripting.html) tutorial.
94 |
95 | ### Format
96 |
97 | Format the contracts:
98 |
99 | ```sh
100 | forge fmt
101 | ```
102 |
103 | ### Gas Usage
104 |
105 | Get a gas report:
106 |
107 | ```sh
108 | forge test --gas-report
109 | ```
110 |
111 | ### Test
112 |
113 | Run the tests:
114 |
115 | ```sh
116 | forge test
117 | ```
118 |
119 | ## Notes
120 |
121 | 1. Foundry uses [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to manage dependencies. For
122 | detailed instructions on working with dependencies, please refer to the
123 | [guide](https://book.getfoundry.sh/projects/dependencies.html) in the book
124 | 2. You don't have to create a `.env` file, but filling in the environment variables may be useful when debugging and
125 | testing against a fork.
126 |
127 | ## License
128 |
129 | This project is licensed under MIT.
130 |
--------------------------------------------------------------------------------
/foundry/erc20/foundry.toml:
--------------------------------------------------------------------------------
1 | [profile.default]
2 | solc = "0.8.20"
3 | bytecode_hash = "none"
4 | optimizer_runs = 1000000
5 |
6 | [profile.intense.fuzz]
7 | runs = 10000
8 |
9 | [fmt]
10 | bracket_spacing = true
11 | int_types = "long"
12 | line_length = 120
13 | multiline_func_header = "all"
14 | number_underscore = "thousands"
15 | quote_style = "double"
16 | tab_width = 4
17 | wrap_comments = true
18 |
19 |
20 | [rpc_endpoints]
21 | bitfinity = "${BITFINITY_RPC_URL}"
22 |
--------------------------------------------------------------------------------
/foundry/erc20/remappings.txt:
--------------------------------------------------------------------------------
1 | openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/
--------------------------------------------------------------------------------
/foundry/erc20/script/Acacia.s.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.20;
3 |
4 | import "forge-std/Script.sol";
5 | import "../src/Acacia.sol";
6 |
7 |
8 | contract AcaciaScript is Script {
9 | function run() external {
10 | uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
11 | vm.startBroadcast(deployerPrivateKey);
12 |
13 | Acacia token = new Acacia(10000000000000000000);
14 |
15 | vm.stopBroadcast();
16 | }
17 | }
--------------------------------------------------------------------------------
/foundry/erc20/src/Acacia.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity 0.8.20;
3 |
4 | import "openzeppelin-contracts/token/ERC20/ERC20.sol";
5 |
6 | contract Acacia is ERC20 {
7 | constructor(uint256 initialSupply) ERC20("Acacia", "ACA") {
8 | _mint(msg.sender, initialSupply);
9 | }
10 |
11 | function decimals() public pure override(ERC20) returns (uint8) {
12 | return 0;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/hardhat/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bitfinity-network/bitfinity-evm-examples/91de96ea859d62d9db494691ad4a5f0c4d49d791/hardhat/.DS_Store
--------------------------------------------------------------------------------
/hardhat/deterministic-deployer-example/.env.example:
--------------------------------------------------------------------------------
1 | PRIVATE_KEY=
2 |
--------------------------------------------------------------------------------
/hardhat/deterministic-deployer-example/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
3 | #Hardhat files
4 | cache
5 | artifacts
6 | factories
7 | typechain
8 |
9 | yarn.lock
10 |
11 | .env
12 |
13 | typechain/*
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/hardhat/deterministic-deployer-example/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "arrowParens": "avoid",
3 | "bracketSpacing": true,
4 | "endOfLine":"auto",
5 | "printWidth": 120,
6 | "singleQuote": false,
7 | "tabWidth": 2,
8 | "trailingComma": "all",
9 | "overrides": [
10 | {
11 | "files": "*.sol",
12 | "options": {
13 | "tabWidth": 4
14 | }
15 | }
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/hardhat/deterministic-deployer-example/LICENSE:
--------------------------------------------------------------------------------
1 | # MIT License
2 |
3 | Copyright (c) 2023 Bitfinity Network
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/hardhat/deterministic-deployer-example/README.md:
--------------------------------------------------------------------------------
1 | # Deterministic Deployer for Hardhat Example
2 |
3 | This example shows how to deploy a contract to Bitfinity network using deterministic deployer. It uses Arachnid deployer found [here]().
4 |
5 | ## About
6 |
7 | This project is a Hardhat project. It is ready to compile and deploy smart contracts locally and on Bitfinity network.
8 |
9 | It uses:
10 |
11 | - [Hardhat](https://github.com/nomiclabs/hardhat): compile and run the smart contracts on a local development network
12 | - [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript types for smart contracts
13 | - [Ethers](https://github.com/ethers-io/ethers.js/): renowned Ethereum library and wallet implementation
14 |
15 | ## Usage
16 |
17 | ### Pre Requisites
18 |
19 | Before running any command, make sure to install dependencies:
20 |
21 | ```sh
22 | yarn install
23 | ```
24 |
25 | ### Compile
26 |
27 | Compile the smart contracts with Hardhat:
28 |
29 | ```sh
30 | yarn compile
31 | ```
32 |
33 | ### Deploy contract to network
34 |
35 | ```sh
36 | npx hardhat run --network bitfinity ./scripts/deploy.ts
37 | ```
38 |
39 | ## Thanks
40 |
41 | If you like it than you shoulda put a start ⭐ on it
42 |
43 | ## License
44 |
45 | MIT
46 |
--------------------------------------------------------------------------------
/hardhat/deterministic-deployer-example/contracts/TestToken.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity ^0.8.0;
3 |
4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5 | import "@openzeppelin/contracts/access/AccessControl.sol";
6 |
7 | /**
8 | * @notice A mintable ERC20
9 | */
10 | contract TestToken is ERC20, AccessControl {
11 | bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
12 |
13 | constructor() ERC20("Test Token", "TST") {
14 | _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
15 | _setupRole(MINTER_ROLE, msg.sender);
16 | }
17 |
18 | function mint(address to, uint256 amount) external {
19 | require(hasRole(MINTER_ROLE, msg.sender), "Only minter can mint");
20 | _mint(to, amount);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/hardhat/deterministic-deployer-example/hardhat.config.ts:
--------------------------------------------------------------------------------
1 | import { HardhatUserConfig } from "hardhat/config";
2 | import "@nomicfoundation/hardhat-toolbox";
3 |
4 | import { config as dotenvConfig } from "dotenv";
5 | import { resolve } from "path";
6 | dotenvConfig({ path: resolve(__dirname, "./.env") });
7 |
8 |
9 | const PRIVATE_KEY = process.env.PRIVATE_KEY || "";
10 |
11 |
12 | // You need to export an object to set up your config
13 | // Go to https://hardhat.org/config/ to learn more
14 | const config: HardhatUserConfig = {
15 | defaultNetwork: "hardhat",
16 | networks: {
17 | hardhat: {
18 | },
19 | bitfinity: {
20 | url: "https://testnet.bitfinity.network",
21 | accounts: ["0x"+ PRIVATE_KEY],
22 | chainId: 355113,
23 | },
24 | localhost: {
25 | url: "http://127.0.0.1:8545",
26 | accounts: ["0x" + PRIVATE_KEY],
27 | chainId: 355113,
28 | }
29 | },
30 | solidity: {
31 | compilers: [
32 | {
33 | version: "0.8.20",
34 | settings: {
35 | optimizer: {
36 | enabled: true,
37 | runs: 200,
38 | },
39 | },
40 | },
41 | ],
42 | },
43 | typechain: {
44 | outDir: "typechain",
45 | target: "ethers-v5",
46 | },
47 | };
48 |
49 | export default config;
50 |
--------------------------------------------------------------------------------
/hardhat/deterministic-deployer-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "deterministic-deployments",
3 | "version": "0.0.3",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "compile": "npx hardhat compile",
8 | "clean": "rm -rf ./artifacts ./cache ./typechain "
9 | },
10 | "author": "Bitfinity Network",
11 | "license": "MIT",
12 | "devDependencies": {
13 | "@ethersproject/abi": "^5.7.0",
14 | "@ethersproject/providers": "^5.7.1",
15 | "@nomicfoundation/hardhat-chai-matchers": "^1.0.4",
16 | "@nomicfoundation/hardhat-network-helpers": "^1.0.6",
17 | "@nomicfoundation/hardhat-toolbox": "^2.0.0",
18 | "@nomiclabs/hardhat-ethers": "^2.2.0",
19 | "@nomiclabs/hardhat-etherscan": "^3.1.7",
20 | "@typechain/ethers-v5": "^10.1.0",
21 | "@typechain/hardhat": "^6.1.3",
22 | "@types/chai": "^4.2.0",
23 | "@types/mocha": "^10.0.4",
24 | "@types/node": "^18.11.2",
25 | "chai": "^4.3.10",
26 | "dotenv": "^16.3.1",
27 | "ethers": "^5.7.1",
28 | "hardhat": "^2.12.0",
29 | "hardhat-gas-reporter": "^1.0.9",
30 | "solidity-coverage": "^0.8.5",
31 | "ts-node": "^10.9.1",
32 | "typechain": "^8.1.0",
33 | "typescript": "^4.8.4"
34 | },
35 | "dependencies": {
36 | "@openzeppelin/contracts": "^4.7.3"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/hardhat/deterministic-deployer-example/scripts/deploy.ts:
--------------------------------------------------------------------------------
1 | // We require the Hardhat Runtime Environment explicitly here. This is optional
2 | // but useful for running the script in a standalone fashion through `node
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
Pete's Pet Shop
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
Scrappy
40 |
41 |
42 |
43 |
44 | Breed: Golden Retriever
45 | Age: 3
46 | Location: Warren, MI