Documentation for Eclipse with EVM

This guide explains everything you need to know to use an Eclipse EVM chain.

Introduction to EVM Deployment

Deploying a Solidity smart contract on an Eclipse EVM chain is similar to deploying on any Ethereum-compatible chain, with a few differences. We'll show you how to deploy a simple "Hello World" Solidity contract using Hardhat.
Hardhat is a powerful and flexible Ethereum development environment that uses JavaScript or TypeScript with support for a wide variety of plugins and extensions.
Other popular Ethereum dev environments include Brownie and Truffle. All of them will work with Eclipse's EVM chains.
You'll have to do a few things before you can deploy your smart contract to the EVM chain.

Install Dependencies

We'll have to install Node.js and npm using, which will be used later in this guide.
Visit the official Node.js download page and download the installation binary for your system. Versions recommended are 14.0 and above.
npm is bundled with the Node.js installation, so you don't have to install it separately.

Installing Hardhat

We'll install Hardhat globally using the npm.
npm install --global hardhat

Initiating a Project

Run the following commands to get initialise a Hardhat project.
mkdir eclipse-evm
cd /eclipse-evm
npx hardhat
Choose Create a JavaScript project from the options presented to you, this will generate all the boilerplate code we need to deploy our smart contract.

Acquiring Testnet Tokens

We need to claim testnet tokens to pay for transaction fees to deploy your smart contract to the testnet.
Use the below command request tokens from our faucet, replace the address with the address of the account from where you want to deploy this contract
curl -X POST https://faucet.evm.eclipse.eclipsenetwork.xyz/request_neon -H 'Content-Type: application/json' -d '{ "wallet": "0xADDRESS", "amount": 1 }'
These testnet tokens are only valid on the testnet and are meant for testing purposes only. Eclipse will never charge you for testnet tokens. Please be wary of scams. Report any suspicious activity to us on our Discord server.

Deploying the Contract

We've setup the project, and gotten our testnet tokens. It's time to deploy finally deploy our smart contract.
Paste the following code in contracts/lock.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MyContract {
string public message;
constructor(string memory _message) {
message = _message;
}
function setMessage(string memory _message) public {
message = _message;
}
}
This simple smart contract allows us to store a string in a variable called message
Now, we'll setup hardhat.config.js with the right parameters
require("@nomiclabs/hardhat-ethers");
module.exports = {
solidity: "0.8.0",
networks: {
eclipse: {
// This the Eclipse EVM chain's RPC
url: "https://evm.eclipse.eclipsenetwork.xyz:8899",
// Replace this with the private key of the wallet you requested testnet tokens
accounts: ["0xYourPrivateKey"],
},
},
};
In scripts/deploy.jsput the following code. This script deploys the smart contract onto the eclipse chain.
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", deployer.address);
const HelloWorld = await ethers.getContractFactory("MyContract");
const helloWorld = await HelloWorld.deploy();
console.log("HelloWorld contract address:", helloWorld.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Finally we can run npx hardhat run scripts/deploy.js --network eclipse You should see an output like this:
Deploying contracts with the account: 0xf39Fd6e51aad8ash8F6F4ce6aB8827279cffFb92266
MyContract deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Just like that, our smart contract has been deployed to Eclipse's EVM testnet!

Integration Instructions

Do you need additional assistance integrating something special like a wallet, bridge, or something else? Feel free to reach out via Discord.