Deploying a contract on StarkNet Testnet2(Goerli 2) using Protostar
In this tutorial, we are going to deploy a contract in Tesnet2 using the Protostar from SwMansion.
We should already have Protostar installed. In my case, I have version 0.8.1. It is the latest version as of today.
If you do not have Protostar installed, you can do it here.
We will use the template provided by Protostar to make the tutorial. In it there is a contract, where you can obtain and increase the balance. To generate it we must execute the command
>>> protostar init
project directory name: hello_world_testnet2
We have to modify the configuration file protostar.toml We must add the following profile pointing to Testnet2.
[profile.testnet2.project]
gateway-url="https://alpha4-2.starknet.io"
chain-id=1536727068981429685321
The file would look like this protostar.toml
We are going to build the project by executing the following command
>>> protostar build
We are ready to deploy to Tesnet2 by executing the following command
>>> protostar -p testnet2 deploy ./build/main.json
Displays the Contract Address and the Transaction hash.
Contract address: 0x00427baaa71a7cb7e61860357a6045afd6a33ce27e5dd64e61f807ae28dc103f
Transaction hash: 0x041087cbdfa5cf53f53bbd52db3ad2f49579cde545397399500c3c9eb90ba881
Let’s go to the StarkScan website and we can see the status of the transaction.
Once the transaction is completed, we access our newly displayed contract.
We already have our contract deployed in Testnet2!!!
- Repository of the tutorial
Bonus:
In case you want to deploy to the devnet you can execute the following command
>>> protostar -p devnet deploy ./build/main.json
Resources:
Send funds to an account in Testnet 2:
- Transferring Goerli ETH to the account (not specific to tesnet 2 but it may help)
- Paradigm MultiFaucet
- Goerli Faucet
- How to get Goerli ETH on Testnet 2