Prerequisites
Ensure that you have a recent version of NodeJs installed. You can check this using the following command:- Linux or Mac: NVM
- Windows: NVM for Windows
You can request EVM testnet funds from the Injective Testnet faucet.
Note that private keys should be handled with caution.
The instructions here should be considered sufficient for local development and Testnet.
However, these are not secure enough for private keys used on Mainnet.
Please ensure that you follow best practices for key security on Mainnet, and do not re-use the same keys/ accounts between Mainnet and other networks.
Set up a new Hardhat project
Use git to clone the demo repo, which already has the project completely set up for you.Orientation
While waiting for npm to download and install, open the repo in your code editor/ IDE, and take a look at the directory structure.hardhat.config.js file is already pre-configured to connect to the Injective EVM Testnet.
All you need to do before proceeding is to provide it with a private key of your Injective Testnet account.
.env file to add the private key.
Optionally, you may wish to update to any alternative JSON-RPC endpoints.
Edit the smart contract
The smart contract that is included in this demo is very basic. It:- Stores one
valuewhich is a number. - Exposes a
value()query method. - Exposes an
increment(num)transaction method.
contracts/Counter.sol
Compile the smart contract
Run the following command:solc) that was configured in the hardhat.config.js file.
Check the compilation output
After the compiler completes, you should see additional directories in the project directory:Counter.json file (artifacts/contracts/Counter.sol/Counter.json).
In it, you should see the compiler outputs, including the abi and bytecode fields.
These artifacts are used in all later steps (test, deploy, verify, and interact).