Deploy a smart contract
Overview for deploying a smart contract with Hardhat, Remix, Foundry, and Thirdweb.
Chain Information
RPC URL: | |
Chain Id: | 123454321 |
Deploy with Hardhat
1. Install Hardhat
Install the hardhat framework in your project, by typing the following command:
2. Create a hardhat project
After installing Hardhat, create a project. You can create it using typescript or javascript in the following screen:
3. Create a Smart contract and Compile protect
After creating the smart contract in the “Contracts” folder, run the following command to check your code.
5. Set the hardhat configuration file and deploy the smart contract
After creating the ignition deploy file, let's set the blockchain information into the hardhat.config file, with the following information:
Deploy with Remix
Remix is a web compiler page where you can write smart contracts, scripts and deploy using your wallet from Metamask. You can enter Remix here.
In the Workspace create the file which contains the Smart contract with the .sol extension.
After writing the smart contract, go to the Solidity Compiler section and select your compiler version, is recommended to use the most recent one.
Then press “Compile” button under the Compiler selector.
3. Select your Metamask wallet as Deploy’s environment
In the “Deploy and Run Transactions” section, move to the Environment and select your Metamask Provider, remember you must be connected to KiiChain Testnet
4. Deploy Smart contract
Select the smart contract to be deployed and write the Constructor parameters is Remix detects them
Finally, you can interact with the different functions in the same section above the Deploy button.
Deploy with Foundry
1. Create a project and installation
Run the following commands in your terminal in order to start the foundry’s installation.
then run the following command in another terminal or restart the current one for finishing the installation process.
After finishing the foundry’s installation let’s create a new project, run the following commands for starting the new project and then move to it’s folder:
2. Write and build a contract
Write your smart contract in ‘/src/smartContractName.sol’ and the script in ‘/script/smartContractName.s.sol’, here is an example of that:
This contract will be placed in the path: /src/Counter.sol
This is the script and will be placed in /script/Counter.s.sol remember to add the .s before the .sol extension.
then run the following command for build and check that everything is correct.
3. Deploy
First, you need to run a simulation.
The simulation will be complete after that, and you can run with broadcast.
A success message should appear.
Deploy with Thirdweb
In this example, we will create a ERC721 (Non fungible token).
1. Create an account
Create an account in thrirdweb, create an API key here, and link your wallet.
Storage the API key in a secure place.
2. Create a project
A message appears
After the installation this screen should appear, select “Contract”
Select the following options:
3. Write a smart contract and deploy
Enter the directory and run the following command:
Open the link and fill in the fields.
In chain choose
add Custom Network
Finally, select Deploy Now and accept the transaction in your wallet.
Confirming Smart Contract on Explorer App
Remember that you can check the smart contracts Deployed here.
Last updated