一些规范:运行在goerli alpha,starknet js 0.4.9上
我正在尝试部署一个预付费的0.5.0 openzeppelin帐户。
我发现类哈希是:ACC_CLASS_HASH=0x750cd490a7cd1572411169eaa8be292325990d33c5d4733655fe6b926985062
然后,我使用这个函数预先计算了地址。
export function calcAddress(mnemonic?: string): string {
const wallet = ethers.Wallet.createRandom();
let currentMnemonic = mnemonic ? mnemonic : wallet.mnemonic.phrase;
console.log(`calculating address for seed : ${currentMnemonic}`);
const starkKeyPair = getStarkPair(currentMnemonic, 0);
let starkKeyPub = ec.getStarkKey(starkKeyPair);
return hash.calculateContractAddressFromHash(starkKeyPub, ACC_CLASS_HASH, [starkKeyPub], 0);
}
然后我把它部署到
export async function deployAcc(mnemonic: string, address: string) {
console.log(`generating keypair from mnemonic`);
const starkKeyPair = getStarkPair(mnemonic, 0);
console.log(`generation succesful`);
const starkKeyPub = ec.getStarkKey(starkKeyPair);
let futureAcc = new Account(provider, address, starkKeyPair);
const accountResponse = await futureAcc?.deployAccount({
classHash: ACC_CLASS_HASH,
constructorCalldata: [starkKeyPub],
addressSalt: starkKeyPub,
contractAddress: address
});
console.log(`tx hash : ${accountResponse?.transaction_hash}`);
await provider.waitForTransaction(accountResponse?.transaction_hash);
}
当我试图部署帐户时,我会一直得到
Entry point 0x36fcbf06cd96843058359e1a75928beacfac10727dab22a3972f0af8aa92895 not found in contract with class hash 0x750cd490a7cd1572411169eaa8be292325990d33c5d4733655fe6b926985062.
进一步搜索入口点0x36fcbf06cd96843058359e1a75928beacfac10727dab22a3972f0af8aa92895使我假设入口点是用于验证调用的?
如图所示,https://starknet.io/docs/hello_starknet/cli.html
提前感谢您的帮助
发布于 2022-11-17 10:06:43
我想您是在询问以下代码:https://github.com/amanusk/starknet-cli-wallet/blob/develop/scripts/deploy-prefunded.ts
正如您正确地指出的,合同中缺少的入口点是__validate_deploy__
。(您可以计算它:)
from starkware.starknet.public.abi import (get_selector_from_name)
print(hex(get_selector_from_name("__validate_deploy__")))
入口点是在版本0.10.1
中引入的,其目的是在首次初始化新帐户时检查帐户部署的有效性。
以上回购协议的当前版本是使用OZ合同版本0.5.0
。此版本尚未实现入口点__validate_deploy__
,因此在尝试部署预付费帐户时会出现此错误。
这应该在PR:https://github.com/OpenZeppelin/cairo-contracts/pull/503中的下一个版本中得到支持。
回购合同将在正式发布后更新。
你可以偷窥到这个分支:https://github.com/amanusk/starknet-cli-wallet/tree/validate-deploy
https://stackoverflow.com/questions/74427394
复制相似问题