56
loading...
This website collects cookies to deliver better user experience
npm install -g yarn hardhat
git clone https://github.com/ethereum-optimism/optimism.git
cd optimism
yarn install
yarn build
cd ops
export COMPOSE_DOCKER_CLI_BUILD=1
export DOCKER_BUILDKIT=1
sudo docker-compose build && echo Build complete
sudo docker-compose up
mkdir MyHardhatProject
cd MyHardhatProject
npx hardhat
yarn add @eth-optimism/hardhat-ovm
contracts/MyContract.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
contract MyContract {
string public hello;
constructor()
{
hello = "Hola mundo!";
}
function setHello(string memory _hello) public {
hello = _hello;
}
}
hardhat.config.js
require("@nomiclabs/hardhat-waffle")
require('@eth-optimism/hardhat-ovm')
task("accounts", "Prints the list of accounts", async () => {
const accounts = await ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
module.exports = {
solidity: "0.7.6",
networks: {
optimistic: {
url: 'http://127.0.0.1:8545',
accounts: { mnemonic: 'test test test test test test test test test test test junk' },
gasPrice: 15000000,
ovm: true // This sets the network as using the ovm and ensure contract will be compiled against that.
}
}
};
npx hardhat compile
npx hardhat console
const MyContract = await ethers.getContractFactory("MyContract")
const my_contract = await MyContract.deploy()
await my_contract.deployed()
await my_contract.hello()
await my_contract.setHello("Probando...")
await my_contract.hello()
56