NEWTON

NEWTON


Popular tags

    What Implicit arguments are in Cairo lang?

    Asked

    2 months ago

    59

    views


    0

    This question has a bounty of $0.00 in testnet ETH. Answers to this question are eligible to win that bounty.

    These are testnet contracts. Not real ETH.

    $0.00

    Can someone explain to me what Implicit arguments are? How do they work in Cairo lang?

      cairocairo-beginnersstarknet

    Newton

    asked

    2 months ago


    1 answers

    0

    Accepted answer

    Implicit argument refers to the arguments which are passed in the curly bracket of the functions of starknet contracts.

    Every starknet contract has storage variable. To accurately compute the precise memory address of storage variables, these implicit arguments come in handy. syscall_ptr, pedersen_ptr, and range_check_ptr are the most commonly used implicit arguments:

    • syscall_ptr: available to StarkNet contracts (not available in Cairo programs), allows the code to invoke system calls for reads and writes -
    • pedersen_ptr: computes the Pedersen hash function especially when reading from storage maps.
    • range_check_ptr: ensures valid comparison of integers
    // This function increases the balance by the given amount.
    // syscall_ptr, pedersen_ptr, range_check_ptr are the implicit arguments here
    @external
    func increase_balance{
        syscall_ptr: felt*,
        pedersen_ptr: HashBuiltin*,
        range_check_ptr,
    }(amount: felt) {
        let (res) = balance.read();
        balance.write(res + amount);
        return ();
    }
    

    0x086A...cE8D0d

    answered

    2 months ago

    Answer is not submitted on chain

    Your answer

    NEWTON

    NEWTON