Skip to content

Commit

Permalink
Update compute_starknet_address.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
futreall authored Nov 6, 2024
1 parent 1001d6c commit e67a2f1
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions cairo/kakarot-ssj/scripts/compute_starknet_address.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
import { hash } from "starknet";
import inquirer from "inquirer";
import { hash } from 'starknet';
import inquirer from 'inquirer';

inquirer
.prompt([
{
type: "input",
name: "classHashInput",
message: "Enter the class hash:",
type: 'input',
name: 'classHashInput',
message: 'Enter the class hash:',
validate: (input) => {
if (input.trim() === '') {
return 'Class hash is required.';
}
if (!/^0x[0-9a-fA-F]+$/.test(input.trim())) {
return "Please enter a valid hexadecimal class hash.";
return 'Please enter a valid hexadecimal class hash.';
}
return true;
},
},
{
type: "input",
name: "saltInput",
message: "Enter the salt:",
default: "0x65766d5f61646472657373",
type: 'input',
name: 'saltInput',
message: 'Enter the salt',
default: '0x65766d5f61646472657373',
validate: (input) => {
if (!/^0x[0-9a-fA-F]+$/.test(input.trim())) {
return "Please enter a valid hexadecimal salt.";
return 'Please enter a valid hexadecimal salt.';
}
return true;
},
},
{
type: "input",
name: "deployerInput",
message: "Enter the deployer address:",
type: 'input',
name: 'deployerInput',
message: 'Enter the deployer address',
default:
"0x7753aaa1814b9f978fd93b66453ae87419b66d764fbf9313847edeb0283ef63",
'0x7753aaa1814b9f978fd93b66453ae87419b66d764fbf9313847edeb0283ef63',
validate: (input) => {
if (!/^0x[0-9a-fA-F]+$/.test(input.trim())) {
return "Please enter a valid hexadecimal deployer address.";
return 'Please enter a valid hexadecimal deployer address.';
}
return true;
},
Expand All @@ -47,14 +50,14 @@ inquirer

const CONSTRUCTOR_CALLDATA = [deployerAddress, salt];

function computeStarknetAddress() {
function compute_starknet_address() {
return hash.calculateContractAddressFromHash(
salt,
classHash,
CONSTRUCTOR_CALLDATA,
deployerAddress,
deployerAddress
);
}

console.log("Pre-computed Starknet Address:", computeStarknetAddress());
console.log('Computed Starknet Address: ' + compute_starknet_address());
});

0 comments on commit e67a2f1

Please sign in to comment.