Starknet Journey(2)-工具

51 阅读1分钟

Using cairo programming language

Scarb

  • A package manager for cairo projects on starknet
  • Similar to Cargo for rust or npm for javascript
  • Official Documentation docs.swmansion.com/scarb/

Starknet Foundry

  • A toolchain for developing Starknet smart contracts. It helps with writing, deploying, and testing your smart contracts. It is inspired by Foundry.

Starkli

  • Starknet Command-line Interface, like query starknet and make transactions and
  • Official Documentation book.starkli.rs/

Deploy a contract

  1. copy private key from EOA
  2. paste command starkli signer keystore from-key account0_keystore.json
    • starkli - starknet cli tool
    • signer - subcommand for managing signing keys/accounts
    • keystore - subcommand for keystore operations
    • from-key - create a keystore file from an existing private key
    • account0_keystore.json - the output filename for your encrypted keystore
  3. you will be prompt to paste your private key, and create a password to encrypt keystore file
  4. starkli account fetch <wallet address> --rpc <sepolia testnet RPC endpoint> --output account0_account.json
  5. The two file account0_account.json and account0_keystore.json enable starkli to sign and send transactions just like your account
  6. scarb build generate target folder, which has contract_class.json
    • compiled bytecode - the actual excecutable contract code
    • ABI Application binary interface
    • contract metadata - information needed for deployment
  7. starkli declare target/dev/*.contract_class.json --rpc <sepolia testnet RPC endpoint> --account account0_account.json --keystore account0_keystore.json
    • starkli - the starknet cli tool
    • declare - uploads your contract bytecode to the network
    • target/dev/two *.contract_class.json path to your compiled contract file

image.png 8. starkli deploy <CLASS HASH DECLARED> --rpc <sepolia testnet RPC endpoint> --account account0_account.json --keystore account0_keystore.json image.png

Starknet Devnet

A local testnet for starknet

Openzeppelin

What is it used for?
This library consists of a set of reuseable components to build custom smart contrats

Introduce some useful modules

Upgrade

provide functions which take care of managing upgradeable deployments of contracts

Access control

what is incredibly important is "who is allowed to do this thing"