Questions tagged [starknet]
33 questions
9
votes
1 answer
Why does this Cairo program put powers of 2 in the memory?
I'm trying to solve this bonus question from the "How Cairo Works" tutorial. I ran the following function, opened the Cairo tracer and saw that the memory is full with powers of 2. Why is that?
func main():
[fp + 1] = 2; ap++
[fp] =…

TorukMakto
- 2,066
- 2
- 24
- 38
6
votes
1 answer
What does it mean to declare a 'local' variable inside a 'let'?
As I understand it, let defines a reference, which can be seen as an alias, so for example let x = y * y * y doesn't compute y * y * y but the occurrences of x will be replaced by y * y * y.
Local variables are similar to other languages local…

Donnoh
- 161
- 10
5
votes
1 answer
How much does storage cost in StarkNet?
If it costs 20000 gas to store a single value in the Ethereum Virtual Machine, how much does it cost in the StarkNet side? Are subsequent updates to the same slot cheaper?
I guess the exact answer probably depends on at least the following:
Rollup…

Lauri Peltonen
- 1,432
- 15
- 29
3
votes
1 answer
How to generate a proof for a Cairo program and verify it?
In SNARKs, you can use Zokrates or snarkjs to generate a proof for a program/computation and verify it, locally or on Ethereum.
Similar to this unanswered question, how to do the same in Cairo and STARK for, say, the 15-puzzle?
Can cairo-run…

sinoTrinity
- 1,125
- 2
- 15
- 27
3
votes
1 answer
when to use tail call optimization in a cairo smartcontract
I can often make a terminal recursive version of my functions with a little less elegant code. Should I do it because it could reduce the fees or should I keep the unoptimised version?
For example, here is an "unoptimised" function which sums…

Th0rgal
- 703
- 8
- 27
2
votes
1 answer
Deploying Cairo contract using Protostar
protostar invoke --contract-address 0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf --function "deployContract" --network testnet --account-address 0x0691622bBFD29e835bA4004e7425A4e9630840EbD11c5269DE51C16774585b16 --max-fee auto…

CCDev
- 23
- 5
1
vote
1 answer
Converting felt252 to ContractAddress in Cairo
How do I create a ContractAddress from a hex value like 0x06D98dC7ea54CF77eeD141F423f6007Dd61fbd2b6bD429Facdf5d4803353063f?
let addr : ContractAddress = 0x06D98dC7ea54CF77eeD141F423f6007Dd61fbd2b6bD429Facdf5d4803353063f; is throwing an exception…

Mathe Eliel
- 658
- 2
- 6
- 16
1
vote
2 answers
Writing StarkNet contracts Error Missing data for required field
I'm trying to declare the sample contract as defined here:
https://www.cairo-lang.org/docs/hello_starknet/intro.html
When invoking
starknet declare --contract contract_compiled.json
result
Error: ValidationError: {'contract_class_version':…

guhao
- 13
- 2
1
vote
2 answers
How to track Starknet L1 costs
I’m trying to track all the gas paid by Starknet on Ethereum.
This Dune board tracks gas spent by SHARP Operator in transactions to Merkle Verifier, FRI Verifier, GPS Verifier and Memory Page Fact Registry.
Where can I find more information about…

Vpum
- 11
- 3
1
vote
1 answer
Recommended way to estimate the fee required to send a message from an L1 contract to a Starknet contract?
I'm sending a message from an Ethereum contract to a Starknet one via the Starknet core contract's sendMessageToL2 function. This function is payable and I'm meant to send ETH to cover the cost of processing the message at the other end. What I…

Alex Sumner
- 11
- 1
1
vote
2 answers
How do you optimize gas in Cairo with Uint256/felt?
I’m learning Cairo and I want to know more about Gas Optimization. In Solidity compiler, there is a difference between writing uint128 and uint256. Similarly to C and other languages, for example:
contract ThisIsNotAnOptimizedContract{
uint128…

QQQ
- 31
- 3
1
vote
1 answer
deploying pre funded OZ account with starknet js
a few specs : running on goerli alpha, starknet js 0.4.9
I am trying to deploy a prefunded 0.5.0 openzeppelin account.
I found the class hash to be : ACC_CLASS_HASH=0x750cd490a7cd1572411169eaa8be292325990d33c5d4733655fe6b926985062
I have then…

bleaknight
- 143
- 8
1
vote
3 answers
what does Starknet ErrorCode "ENTRY_POINT_NOT_FOUND_IN_CONTRACT" mean?
I am new to Cairo and StarkNet. I am running a simple contract given in the following link of Cairo docs. I am following all the steps. After compilation when I am trying to declare the contract it is giving the following error.
Error
Got BadRequest…

Shakeel Khan
- 21
- 4
1
vote
0 answers
Can a block exist in a blockchain before any transaction?
Let's say we're building a blockchain network, is it possible for the genesis block to be created without any transaction?

Nathan Getachew
- 783
- 5
- 16
1
vote
2 answers
HashBuiltin - Cairo
I am having this contract.cairo:3:59: Unknown identifier 'HashBuiltin'
after doing :
starknet-compile contract.cairo
--output contract_compiled.json
--abi contract_abi.json
code :
@external
func increase_balance{syscall_ptr : felt*,…

newway
- 21
- 1
- 5