Contract Deployment
Matchain Development Guide
Already know what you're doing?
Add Matchain
RPC URL: https://rpc.matchain.io
ChainID: 698
Bridge or request gas sponsorship from our team
Hardhat
Hardhat is a development environment for Ethereum-based smart contracts, providing tools for compilation, deployment, testing, and debugging.
Getting Started with Hardhat
Install Hardhat:
npm install --save-dev hardhat
Create a new Hardhat project:
npx hardhat init
Follow the prompts to set up your project.
Configure Hardhat to use Matchain by updating
hardhat.config.js
:module.exports = { solidity: "0.8.17", networks: { matchain: { url: "https://rpc.matchain.io", chainId: 698, accounts: ["YOUR_PRIVATE_KEY"] // Replace with your wallet's private key } } };
Write your smart contract in the
contracts
folder, e.g.,HelloWorld.sol
:// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract HelloWorld { string public greet = "Hello World!"; }
Compile your contract:
npx hardhat compile
Deploy your contract to Matchain:
npx hardhat run scripts/deploy.js --network matchain
Ensure you have a deployment script in the
scripts
folder, e.g.,deploy.js
:async function main() { const HelloWorld = await ethers.getContractFactory("HelloWorld"); const helloWorld = await HelloWorld.deploy(); await helloWorld.deployed(); console.log("Contract deployed to:", helloWorld.address); } main().catch((error) => { console.error(error); process.exitCode = 1; });
Danger! It is very dangerous to use a wallet with valuable assets for development. You could easily write code with a bug that transfers the wrong amount of the wrong token to the wrong address. Transactions cannot be reversed once sent! -> Be safe and use separate wallets for separate purposes.
Remix
What is Remix?
Remix Project is a robust set of tools that can be used by individuals of any skill level throughout the entire process of developing contracts, and it also serves as an educational platform for learning and experimenting with Ethereum.
Getting Started with Remix
Visit Remix.
Navigate to the File Explorer and click the contract button in the top left to create a Smart Contract.
Enter a name for the contract, e.g.,
test.sol
.Input your smart contract or use the sample contract below:
// SPDX-License-Identifier: MIT // compiler version must be greater than or equal to 0.8.17 and less than 0.9.0 pragma solidity ^0.8.17; contract HelloWorld { string public greet = "Hello World!"; }
Navigate to the Solidity Compiler sidebar option and click "Compile."
If you didn't get any errors, let's proceed with deploying it onto the blockchain. But first: Danger! It is very dangerous to use a wallet with valuable assets for development. You could easily write code with a bug that transfers the wrong amount of the wrong token to the wrong address. Transactions cannot be reversed once sent! -> Be safe and use separate wallets for separate purposes.
Deploying Your Smart Contract
Once you have written your Smart Contract in Remix, you can navigate to the sidebar option to Compile your contract.
Navigate to the "Deploy & run transactions" sidebar option.
Change the top ENVIRONMENT dropdown from "Remix VM" to "Injected Web3."
This will prompt MetaMask - Press "Connect" in MetaMask to allow Remix access.
Click the "Deploy" button, and confirm the transaction in MetaMask.
Deploy done!
Congratulations, you've deployed your first contract on Matchain!
Last updated
Was this helpful?