1

I'm trying to declare the sample contract as defined here:

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

When invoking

starknet declare --contract contract_compiled.json

result

Error: ValidationError: {'contract_class_version': ['Missing data for required field.'], 'entry_points_by_type': defaultdict(<class 'dict'>, {'EXTERNAL': {'value': {0: {'function_idx': ['Missing data for required field.'], 'offset': ['Unknown field.']}, 1: {'function_idx': ['Missing data for required field.'], 'offset': ['Unknown field.']}}}}), 'program': ['Unknown field.']}

When invoking

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

result

Error: ValidationError: {'contract_class_version': ['Missing data for required field.'], 'entry_points_by_type': defaultdict(<class 'dict'>, {'EXTERNAL': {'value': {0: {'function_idx': ['Missing data for required field.'], 'offset': ['Unknown field.']}, 1: {'function_idx': ['Missing data for required field.'], 'offset': ['Unknown field.']}}}}), 'program': ['Unknown field.']}

my account has 0.00381910303249468 ETH
account is https://testnet.starkscan.co/contract/0x05a8303a0fb86f6f922c7acd0548a282c46d8c532a069dfa7e1ca22f3f3eef8c#overview

TylerH
  • 20,799
  • 66
  • 75
  • 101
guhao
  • 13
  • 2

2 Answers2

1

I will explain to your how to declare a smart contract using Protostar.

To declare a smart contract, make sure you have configured your account's private key properly on your environment.

Make sure you copy the private key from your wallet(most of the time ArgentX or Braavos) and add it to declare function command.

You can also add it to your .bash_profile file or your environment with the name PROTOSTAR_ACCOUNT_PRIVATE_KEY if you are using protostar.

After you have that set up, make sure your project is built and that you have the .json output file.

With protostar, simply run protostar declare --max-fee auto --account-address $ACCOUNT_ADDR --network testnet ./build/main.json to declare the smart contract.

Core Stars
  • 11
  • 1
1

You are trying to declare a Cairo 0.x contract. The CLI now accepts by default only Cairo 1 contracts. To declare a Cairo 0 contract,you should use the same command and add the flag —-deprecated

Henri
  • 86
  • 3