# 通过Protostar来部署你的第一个Starknet合约(Ubuntu) **Published by:** [天空](https://paragraph.com/@masamii/) **Published on:** 2023-09-07 **URL:** https://paragraph.com/@masamii/protostar-starknet-ubuntu ## Content 默认你已经完成以下准备工作:1, Ubuntu 22.04 2, python3.9 3, vs code 4, 头盔或者人字拖钱包让我们开始吧 o.0一, 安装Protostarcurl -L https://raw.githubusercontent.com/software-mansion/protostar/master/install.sh | bash 检查是否安装成功protostar -v 安装成功后会展示相应版本号你可以在这里检查最新的Protostar版本 二,开始部署你的第一个Starknet合约 在开始前,你需要准备 1, 留有足够测试网Gas(测试网水龙头)的账号以及该账号的私钥 2, 该账号的Class Hash,成功获取后保存起来备用 Class Hash的获取方法如下: 打开这个链接, 将地址栏中你的地址 替换为你的账户地址,然后你将进入以下页面:红圈部分即为你的ClassHash,复制保存备用或者从钱包插件中进入该页面 人字拖1, 打开设置2, 点进去你的账号3, 点击 View on StarkScan 开始启动你的项目吧 在你想要的文件位置进行初始化protostar init my_Second 这样你就创建好了你的第一个Cairo项目通过vs code打开该项目cd mySecond code . 目录结构如下:HelloStarkNet !你已经完成了你的第一个合约编写,接下来我们可以通过Protostar自带的测试功能来测试下该合约是否合格protostar test 显示pass则通过测试测试成功后通过build指令来进行合约编译build成功后,你会发现,protostar为我们生成了一个build的文件夹,并且在控制台为我们生成了一个合约的Class Hash ,相应的我们也把这个我们拿到的第二个Class Hash 保存起来 还记得我们在前面保存的账号私钥和第一个class hash吗? 我们马上在声明合约的时候要用到它 ! 在声明合约之前,我们先要配置我们的账号私钥export PROTOSTAR_ACCOUNT_PRIVATE_KEY=你的私钥 注意私钥后几位尽量手输声明你的合约protostar declare hello_starknet --network testnet --account-address 你的账户地址 --max-fee auto 如果在这一步提示你 …already declared.. ,不用担心,这并不妨碍我们接下来的工作 部署合约protostar deploy 第二个classhash --network testnet --max-fee auto --account-address 你的账户地址 完结撒花至此你就可以在starknet的区块浏览器上玩耍你的合约啦 ! ## Publication Information - [天空](https://paragraph.com/@masamii/): Publication homepage - [All Posts](https://paragraph.com/@masamii/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@masamii): Subscribe to updates - [Twitter](https://twitter.com/TianKon83930304): Follow on Twitter