写StarkNet契约错误缺少必需字段的数据



我试图声明这里定义的示例合约:

https://www.cairo-lang.org/docs/hello_starknet/intro.html

当调用

starknet declare --contract contract_compiled.json

结果

错误:ValidationError: {'contract_class_version':['缺少所需字段的数据。'], 'entry_points_by_type': defaultdict(, {'EXTERNAL': {'value': {0: {'function_idx':['缺少所需字段的数据。'], 'offset':['未知字段。']}, 1: {'function_idx':['缺少所需字段的数据。","抵消":['未知的领域 .']}}}}), ' 项目"("未知的领域。"):}

当调用

starknet declare  --network alpha-goerli --account __default__ --contract contract_compiled.json 

结果

错误:ValidationError: {'contract_class_version':['缺少所需字段的数据。'], 'entry_points_by_type': defaultdict(, {'EXTERNAL': {'value': {0: {'function_idx':['缺少所需字段的数据。'], 'offset':['未知字段。']}, 1: {'function_idx':['缺少所需字段的数据。","抵消":['未知的领域 .']}}}}), ' 项目"("未知的领域。"):}

我的账户有0.00381910303249468 ETH
账户是https://testnet.starkscan.co/contract/0x05a8303a0fb86f6f922c7acd0548a282c46d8c532a069dfa7e1ca22f3f3eef8c#overview

您正在尝试声明Cairo 0。x合同。CLI现在默认只接受Cairo 1契约。要声明Cairo 0契约,应该使用相同的命令并添加标志—-deprecated

我将向您解释如何使用Protostar声明智能合约。

要声明智能合约,请确保您已经在您的环境中正确配置了您的帐户私钥。

确保从钱包中复制私钥(大多数情况下是ArgentX或Braavos)并将其添加到declare function命令中。

你也可以添加到你的.bash_profile文件或PROTOSTAR_ACCOUNT_PRIVATE_KEY名称的environment如果你正在使用protostar

设置完成后,确保项目已经构建,并且有.json输出文件。

使用protostar,只需运行protostar declare --max-fee auto --account-address $ACCOUNT_ADDR --network testnet ./build/main.json来声明智能合约。

最新更新