Created
April 14, 2022 22:12
-
-
Save lsbyerley/ddfa56d94ab8a850eb2257797955790d to your computer and use it in GitHub Desktop.
Deploy and Initialize Starknet Account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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