Prerequisites
You should already have a Hardhat project set up, and have compiled your smart contract successfully. See the set up Hardhat and compile a smart contract tutorial for how to do so. Optionally, but strongly recommended: You should also have tested your smart contract successfully. See the test a smart contract using Hardhat tutorial for how to do so.Edit the deployment script
In order for the smart contract that you have compiled on your computer to exist on the Injective Testnet, it needs to be deployed onto the network. To do so, we will make use of a script that uses anethers instance that is pre-configured by Hardhat using the values specified in hardhat.config.js.
Open the file: script/deploy.js
artifacts/contracts/Counter.sol/Counter.json? In this script, ethers.getContractFactory('Counter') retrieves that file, and extracts ABI and EVM bytecode from it.
The following lines use that information to construct a deployment transaction and submit it to the network.
If successful, the address at which your smart contract was deployed will be output, for example:
0x98798cc92651B1876e9Cc91EcBcfe64cac720a1b
Note that on other EVM networks, transactions (including deployment transactions), do not need to specify a gas price and a gas limit. Currently, however, this is necessary on Injective.
Run the deployment script
Run the following command to deploy the smart contract:https://testnet.blockscout.injective.network, and paste the address in the search field.
You’ll visit the smart contract page in the block explorer for the smart contract that you have just deployed.
If you click on the “Contract” tab, you should see the EVM bytecode for that contract, and it will match the EVM bytecode found in your artifacts directory after compilation.