NEWTON
Asked
4 months ago
72
views
0
I try to implement the function abs_value
of the package starkware.cairo.common.math
but i have this error
AssertionError: Expected main to contain the following arguments (in this order): ['range_check_ptr_ptr']. Found: ['range_check_ptr'].
I dont understand the error.
Can someone explain the error to me, why it happens ?
I am doing the challenge #17daysOfCairo of the day 3
Full code
%builtins range_check_ptr
from starkware.cairo.common.math import abs_value
func main{range_check_ptr}() {
let x = abs_value(-1);
return ();
}
1
Accepted answer
You actually don't need to import the range_check_ptr
but actually the range_check
built-in (check this link). Change your code to
%builtins range_check
from starkware.cairo.common.math import abs_value
func main{range_check_ptr}() {
let x = abs_value(-1);
return ();
}
and it should compile and run.
answered
4 months ago
How to divide felt in Cairo Lang using unsigned_div_rem?
Cairo Lang / StarkNet: What are Revoked references? What is alloc_locals?
How to use get_fp_and_pc in Cairo Lang?
What is the difference between tempvar/let in Cairo Lang? How to use allow_locals and local?
How to use Hints in Cairo Lang?
How to make recursive function in Cairo Lang?
How to make Bitwise operations in Cairo Lang using %builtins bitwise, bitwise_xor?
How can I get ETH for the test net in StarkNet?
Cairo: Getting the zero address
What will the bundler ecosystem look like in Account Abstraction?
How expensive are bitwise operations (and/or/xor) vs arithmetic in Cairo?
Status “received” while deploying starknet transaction. Is it ok?
How can I use meta-class of contract (starknetjs) for interaction?
A TypeError while unpacking nested tuples into felts