Skip to content

Commit

Permalink
Create interact_with_rollup.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Oct 20, 2024
1 parent 1b34e50 commit 8314615
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// interact_with_rollup.js
const { ethers } = require("hardhat");

async function main() {
const [owner, operator] = await ethers.getSigners();

// Assuming the addresses of the deployed contracts are known
const rollupManagerAddress = "YOUR_ROLLUP_MANAGER_ADDRESS";
const rollupAddress = "YOUR_ROLLUP_ADDRESS";
const rollupValidatorAddress = "YOUR_ROLLUP_VALIDATOR_ADDRESS";

const Rollup = await ethers.getContractAt("Rollup", rollupAddress);
const RollupManager = await ethers.getContractAt("RollupManager", rollupManagerAddress);
const RollupValidator = await ethers.getContractAt("RollupValidator", rollupValidatorAddress);

// Add an operator
await RollupManager.connect(owner).addOperator(operator.address);
console.log("Operator added:", operator.address);

// Create a batch
const stateRoot = ethers.utils.keccak256(ethers.utils.toUtf8Bytes("Sample State Root"));
await Rollup.connect(operator).createBatch(stateRoot);
console.log("Batch created with state root:", stateRoot);

// Validate a transaction
await RollupValidator.connect(operator).validateTransaction(stateRoot, operator.address);
console.log("Transaction validated for operator:", operator.address);
}

// Execute the interaction script
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit 8314615

Please sign in to comment.