Skip to content

Instantly share code, notes, and snippets.

@milancermak
Created May 30, 2023 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milancermak/d1839b6d8279e14277169569d1955fd0 to your computer and use it in GitHub Desktop.
Save milancermak/d1839b6d8279e14277169569d1955fd0 to your computer and use it in GitHub Desktop.
A short on how to declare & deploy to Starknet right now

Make sure you have the right version of the tools you need:

  1. cairo v1.1.0 (check out the tag)
  2. cairo-lang v0.11.2

Set up the env

export STARKNET_NETWORK=alpha-goerli
export STARKNET_WALLET=starkware.starknet.wallets.open_zeppelin.OpenZeppelinAccount

you also need an CLI account - you can check ~/.starknet_accounts/starknet_open_zeppelin_accounts.json if you have some or do starknet new_account --account experiments to get an address, then fund it with some goerli ETH and then starknet deploy_account --account experiments

compile the contract using the built cairo binaries

cairo/target/release/starknet-copmile contract.cairo > contract.json

now declare the contract

starknet declare --contract contract.json --account experiments --max_fee 10000000000000000

that will give you a contract class hash which you'll need in the deploy step; monitor for the TX to pass (at least "pending" I think)

to deploy, the easiest way from CLI is to use the UDC - the deploy is done by invoking a contract that's basically a wrapper around a deploy syscall

starknet invoke --address 0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf --abi ./UDC_abi.json --function deployContract --inputs CLASS_HASH_FROM_DECLARE_TX SALT UNIQUE_FLAG CTOR_DATA_LEN CTOR_DATA --account experiments

monitor this TX on Starkscan; to get the address of the deployed contract, check the ContractDeploy event that this TX emits, specifically the address field


it's also possible to declare and deploy via ArgentX - in some Developer tools submenu, there's an option to do that

[
{
"data": [
{
"name": "address",
"type": "felt"
},
{
"name": "deployer",
"type": "felt"
},
{
"name": "unique",
"type": "felt"
},
{
"name": "classHash",
"type": "felt"
},
{
"name": "calldata_len",
"type": "felt"
},
{
"name": "calldata",
"type": "felt*"
},
{
"name": "salt",
"type": "felt"
}
],
"keys": [],
"name": "ContractDeployed",
"type": "event"
},
{
"name": "deployContract",
"type": "function",
"inputs": [
{
"name": "classHash",
"type": "felt"
},
{
"name": "salt",
"type": "felt"
},
{
"name": "unique",
"type": "felt"
},
{
"name": "calldata_len",
"type": "felt"
},
{
"name": "calldata",
"type": "felt*"
}
],
"outputs": [
{
"name": "address",
"type": "felt"
}
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment