Skip to content

Commit

Permalink
Fix zkapp address
Browse files Browse the repository at this point in the history
  • Loading branch information
xqft committed Sep 27, 2024
1 parent 152292b commit e9afbf0
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ ETH_CHAIN=<devnet/holesky>
MINA_RPC_URL=<url>
SAVE_PROOF=true/false # also false if other than "true" or variable were to be not defined

## A Mina fee payer account is needed for running the Sudoku example
#FEEPAYER_KEY=<private_key>

## These can be skipped if using devnet with Anvil.
# BATCHER_ADDR=<optional>
# BATCHER_ETH_ADDR=<optional>
Expand Down
2 changes: 0 additions & 2 deletions core/src/utils/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ pub const MINA_HASH_SIZE: usize = 32;

// Bridge related constants
pub const BRIDGE_DEVNET_ETH_ADDR: &str = "0x700b6A60ce7EaaEA56F065753d8dcB9653dbAD35";
pub const BRIDGE_HOLESKY_ETH_ADDR: &str = "0x4Eb39dB24B0E89D49dD082EA68d6aab6514C613B";
pub const BRIDGE_TRANSITION_FRONTIER_LEN: usize = 16;
pub const BRIDGE_ACCOUNT_DEVNET_ETH_ADDR: &str = "0xA15BB66138824a1c7167f5E85b957d04Dd34E468";
pub const BRIDGE_ACCOUNT_HOLESKY_ETH_ADDR: &str = "0x148Ff17B5142B85Bf387baF48b8681ccc014A3c9";

// Aligned related constants
pub const PROOF_GENERATOR_ADDR: &str = "0x66f9664f97F2b50F62D13eA064982f936dE76657";
Expand Down
2 changes: 1 addition & 1 deletion example/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use mina_bridge_core::{
};
use std::{process, str::FromStr, time::SystemTime};

const MINA_ZKAPP_ADDRESS: &str = "B62qkAgG7MFhpemxLsveJC7Xr5G1RmkbttJjASAxeQR3sGGHQWQN3HP";
const MINA_ZKAPP_ADDRESS: &str = "B62qmpq1JBejZYDQrZwASPRM5oLXW346WoXgbApVf5HJZXMWFPWFPuA";
const SUDOKU_VALIDITY_DEVNET_ADDRESS: &str = "0xb19b36b1456E65E3A6D514D3F715f204BD59f431";
const SUDOKU_VALIDITY_HOLESKY_ADDRESS: &str = "0xeAB6068E1e06941A9d47734FB49C3B9dD69E054d";

Expand Down
15 changes: 15 additions & 0 deletions example/mina_zkapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions example/mina_zkapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@
},
"engines": {
"node": ">=18.14.0"
},
"dependencies": {
"dotenv": "^16.4.5"
}
}
51 changes: 14 additions & 37 deletions example/mina_zkapp/src/run.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,25 @@
import fs from 'fs/promises';
import path from 'path';
import { Sudoku, SudokuZkApp } from './sudoku.js';
import { generateSudoku, solveSudoku } from './sudoku-lib.js';
import { Mina, PrivateKey, NetworkId, fetchAccount } from 'o1js';
import { Mina, PrivateKey, NetworkId, fetchAccount, PublicKey } from 'o1js';
import dotenv from 'dotenv';

const TX_MAX_TRIES = 5;
const DEPLOY_ALIAS = "devnet";

type Config = {
deployAliases: Record<
string,
{
networkId?: string;
url: string;
keyPath: string;
fee: string;
feepayerKeyPath: string;
feepayerAlias: string;
}
>;
};
dotenv.config({ path: '../../.env' });

let configJson: Config = JSON.parse(await fs.readFile('config.json', 'utf8'));
let config = configJson.deployAliases[DEPLOY_ALIAS];

let feepayerKeysBase58: { privateKey: string; publicKey: string } = JSON.parse(
await fs.readFile(config.feepayerKeyPath, 'utf8')
);
let zkAppKeysBase58: { privateKey: string; publicKey: string } = JSON.parse(
await fs.readFile(config.keyPath, 'utf8')
);
let feepayerKey = PrivateKey.fromBase58(feepayerKeysBase58.privateKey);
let zkAppKey = PrivateKey.fromBase58(zkAppKeysBase58.privateKey);
const TX_MAX_TRIES = 5;
const FEE = 0.1; // in MINA

let feepayerKey = PrivateKey.fromBase58(process.env.FEEPAYER_KEY as string);
let feepayerAddress = feepayerKey.toPublicKey();
let zkAppAddress = zkAppKey.toPublicKey();

let zkAppAddress = PublicKey.fromBase58("B62qmKCv2HaPwVRHBKrDFGUpjSh3PPY9VqSa6ZweGAmj9hBQL4pfewn");

// define network (devnet)
const Network = Mina.Network({
// We need to default to the testnet networkId if none is specified for this deploy alias in config.json
// This is to ensure the backward compatibility.
networkId: config.networkId as NetworkId,
mina: config.url,
networkId: "testnet" as NetworkId,
mina: "https://api.minascan.io/node/devnet/v1/graphql",
});
const fee = Number(config.fee) * 1e9; // in nanomina (1 billion = 1.0 mina)
const fee = Number(FEE) * 1e9; // in nanomina (1 billion = 1.0 mina)
Mina.setActiveInstance(Network);

// define zkapp and create sudoku to upload
Expand All @@ -55,7 +32,7 @@ const sudoku = generateSudoku(0.5);
console.log('Compiling Sudoku');
await SudokuZkApp.compile();

console.log("Sending update transaction and waiting until it's included in a block");
console.log("Sending update transaction");
await trySendTx(
{ sender: feepayerAddress, fee },
async () => {
Expand All @@ -77,7 +54,7 @@ console.log('Is the sudoku solved?', zkApp.isSolved.get().toBoolean());
async function trySendTx(sender: Mina.FeePayerSpec, f: () => Promise<void>) {
for (let i = 1; i <= TX_MAX_TRIES; i++) {
try {
console.log("Defining transaction");
console.log("Define new transaction");
const tx = await Mina.transaction(sender, f);

console.log("Proving transaction");
Expand Down

0 comments on commit e9afbf0

Please sign in to comment.