reference:
https://book.starknet.io/chapter_3/protostar.html

tools:
https://www.stark-utils.xyz/converter

protostar test
protostar build

Contract Declaration

After successfully compiling your project, the next step is to declare your contracts. This process informs the network of your intention to deploy a new contract (review Chapter 2 for more details on the contract declaration process).

Before declaring contracts, it’s essential to first set the environment variable for your private key:

export PROTOSTAR_ACCOUNT_PRIVATE_KEY=0x...

You can then declare your contracts with the following command:

protostar declare hello_starknet \
  --network testnet \
  --account-address YOUR_ACCOUNT_ADDRESS \
  --max-fee auto

Note: Replace YOUR_ACCOUNT_ADDRESS with your actual account address.

Successful declaration will generate a class hash and output similar to:

Declare transaction was sent.
Class hash: 0x04ad47b818e8811a8c1df2a03a26381da0232bb7da3cba274831c2cfc9953acd
StarkScan https://testnet.starkscan.co/class/0x04ad47b818e8811a8c1df2a03a26381da0232bb7da3cba274831c2cfc9953acd
Voyager   https://goerli.voyager.online/class/0x04ad47b818e8811a8c1df2a03a26381da0232bb7da3cba274831c2cfc9953acd
Transaction hash: 0x03d048f8dc599c7d9bad1e5a7a039c35463b9479f0966766bc0df03cd89d6d7d
StarkScan https://testnet.starkscan.co/tx/0x03d048f8dc599c7d9bad1e5a7a039c35463b9479f0966766bc0df03cd89d6d7d
Voyager   https://goerli.voyager.online/tx/0x03d048f8dc599c7d9bad1e5a7a039c35463b9479f0966766bc0df03cd89d6d7d
21:01:23 [INFO] Execution time: 27.95 s

Contract Deployment

After declaring your contract, the next step is to deploy it on the network. Deployment makes your contract live and interactable on the Starknet.

To deploy your contract, use the class hash generated from the declaration step and the protostar deploy command:

protostar deploy \
  0x04ad47b818e8811a8c1df2a03a26381da0232bb7da3cba274831c2cfc9953acd \
  --network testnet \
  --account-address YOUR_ACCOUNT_ADDRESS \
  --max-fee auto

Note: Replace YOUR_ACCOUNT_ADDRESS with your actual account address.

The ‘0x’ address following the deploy command is the Class Hash that was generated during contract declaration.

Successful deployment will provide a contract address and output similar to this:

Invoke transaction was sent to the Universal Deployer Contract.
Contract address: 0x02341c459847cf220671ab873e14d853197c74e239c3b5815b0aa2e85bc37ebd
StarkScan https://testnet.starkscan.co/contract/0x02341c459847cf220671ab873e14d853197c74e239c3b5815b0aa2e85bc37ebd
Voyager   https://goerli.voyager.online/contract/0x02341c459847cf220671ab873e14d853197c74e239c3b5815b0aa2e85bc37ebd
Transaction hash: 0x03406b79b189d8752cff632ea8e0df332d7be7e27ffbc453fbf210c7384c0676
StarkScan https://testnet.starkscan.co/tx/0x03406b79b189d8752cff632ea8e0df332d7be7e27ffbc453fbf210c7384c0676
Voyager   https://goerli.voyager.online/tx/0x03406b79b189d8752cff632ea8e0df332d7be7e27ffbc453fbf210c7384c0676
21:25:26 [INFO] Execution time: 3.22 s