Skip to content

Instantly share code, notes, and snippets.

@lsbyerley
Created April 14, 2022 22:12
Show Gist options
  • Save lsbyerley/ddfa56d94ab8a850eb2257797955790d to your computer and use it in GitHub Desktop.
Save lsbyerley/ddfa56d94ab8a850eb2257797955790d to your computer and use it in GitHub Desktop.
Deploy and Initialize Starknet Account
const fs = require('fs');
const starknet = require('starknet');
const { ec, defaultProvider, json, Contract } = starknet;
const starkKeyPair = ec.getKeyPair(user.privateKey);
const starkKeyPub = ec.getStarkKey(starkKeyPair);
const compiledArgentAccount = json.parse(fs.readFileSync('./utils/ArgentAccount.json').toString('ascii'));
const accountResponse = await defaultProvider.deployContract({
contract: compiledArgentAccount,
addressSalt: starkKeyPub,
});
await defaultProvider.waitForTransaction(accountResponse.transaction_hash);
console.log(`LOG: view tx: https://goerli.voyager.online/tx/${accountResponse.transaction_hash}`);
const accountContract = new Contract(compiledArgentAccount.abi, accountResponse.address);
const initializeResponse = await accountContract.initialize(starkKeyPub, '0');
await defaultProvider.waitForTransaction(initializeResponse.initializeTxHash);
//TODO: Never gets to this log, initalizing contract 'NOT_RECEIVED'
console.log(`LOG: view tx: https://goerli.voyager.online/tx/${initializeResponse.initializeTxHash}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment