Quickstart
Last updated
Was this helpful?
Was this helpful?
mkdir rome-hello && cd rome-hello
npm init -y
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat initrequire("@nomicfoundation/hardhat-toolbox");
module.exports = {
solidity: "0.8.28",
networks: {
rome_devnet: {
url: "https://montispl.devnet.romeprotocol.xyz",
chainId: 200002,
accounts: [process.env.PRIVATE_KEY],
},
rome_local: {
url: "http://localhost:9090",
chainId: 1001,
accounts: [process.env.PRIVATE_KEY],
},
},
};export PRIVATE_KEY="0xYOUR_PRIVATE_KEY"// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
contract HelloRome {
string public greeting = "Hello from Solana!";
uint256 public counter;
event Greeted(address indexed sender, uint256 count);
function greet() external returns (string memory) {
counter++;
emit Greeted(msg.sender, counter);
return greeting;
}
function setGreeting(string calldata _greeting) external {
greeting = _greeting;
}
}const hre = require("hardhat");
async function main() {
const HelloRome = await hre.ethers.getContractFactory("HelloRome");
const hello = await HelloRome.deploy();
await hello.waitForDeployment();
const address = await hello.getAddress();
console.log("HelloRome deployed to:", address);
// Call the contract
const tx = await hello.greet();
await tx.wait();
const count = await hello.counter();
console.log("Counter:", count.toString());
const greeting = await hello.greeting();
console.log("Greeting:", greeting);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});npx hardhat run scripts/deploy.js --network rome_devnetHelloRome deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
Counter: 1
Greeting: Hello from Solana!